Unable to modify data on i-Series DB2 from .NET
I am having an application in .NET that uses Entity Framework 4. I am using the DB2/400 as my applica开发者_运维技巧tion 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)
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.
精彩评论