无法从 .NET 修改 i-Series DB2 上的数据
我在 .NET 中有一个使用 Entity Framework 4 的应用程序。我使用 DB2/400 作为我的应用程序后端。我能够进行查询并从数据库中成功读取。 但是,在任何其他操作(例如插入/更新/删除)中,我都会收到错误。 我在 http://www.ibm.com/developerworks/ 找到了答案forums/thread.jspa?messageID=14222306 其中指出我的 DB2 客户端驱动程序未针对事务进行配置。 但是,在 /sqllib/cfg 文件夹下不存在 db2cli.cfg 文件(或我计算机上的其他任何位置) 另外,我可以从绿屏/java 应用程序修改表。 这是我的方法之一:
using (var context = new Data.SchemaEntity()) {
string sql = "select * from schemaname.tablename where FLD='V2'";
var rows = context.ExecuteStoreQuery<CUST>(sql, null);
CUST c = rows.First(); // This is giving me the correct data
if(c.EntityState == System.Data.EntityState.Detached)
context.CUSTS.Attach(c);
context.CUSTS.DeleteObject(c);
context.SaveChanges();
}
我的问题是:
- 我是否应该选择另一个版本/安装 DB2 Express-C 安装 .NET 驱动程序/提供程序。
- 我可以使用任何其他方法吗 实体框架内的数据持久化(例如在 jpa/hibernate 我们可以使用显式事务)。
如果您有任何想法(我可以尝试,请在此处提及)
I am having an application in .NET that uses Entity Framework 4. I am using the DB2/400 as my application backend. I am able to make queries and read successfully from the database.
However on any other operation (such as insert/update/delete), I am getting errors.
I found the answer at http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14222306 which stated that my DB2 client driver was not configured for transactions.
However, under /sqllib/cfg folder there is no db2cli.cfg file present (or anywhere else on my computer)
Also, I am able to modify the tables from the green screen/java application.
Here is one of my methods :
using (var context = new Data.SchemaEntity()) {
string sql = "select * from schemaname.tablename where FLD='V2'";
var rows = context.ExecuteStoreQuery<CUST>(sql, null);
CUST c = rows.First(); // This is giving me the correct data
if(c.EntityState == System.Data.EntityState.Detached)
context.CUSTS.Attach(c);
context.CUSTS.DeleteObject(c);
context.SaveChanges();
}
My questions are :
- Should I go for another versions/ installation of DB2 express-C that
installs the .NET driver/provider. - Can I use any other approach for
data persistence within the entity framework (for example in
jpa/hibernate we can use explicit Transactions).
If you've got any ideas (That I can possibly try, please do mention here)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在使用带有 i 的实体框架方面运气不佳。通常,我刚刚使用了 IBM i Access 的 ADO.NET 驱动程序。抱歉我没有更好的答案给你。几个月来我一直在寻找适用于 i 的 EF 驱动程序。
I haven't had much luck with using entity framework with the i. Typically, I have just used the ADO.NET driver from IBM i Access. Sorry I don't have a better answer for you. I have been looking for months for a EF driver for the i.