Hi
I am using a DataContext build on Oracle 11g, I have a type called VSpsk and I need to put some new objects into my Table, like this
var vs = new Vspsk();
vs.Id = 1;
vs.Name = 2;
var ls = Context.GetTable<Vspsk>();
ls.InsertOnSubmit(vs);
var q = ls.FirstOrDefault(v => v.Id.Equals(1));
Why is q null at this point ?
I can see Context.ChangeSet.Inserts contains the object -
am I supposed to join myself ?
Or is there some other way to do this without calling the database ?
Best regards
Glenn
InsertOnSubmit
Re: InsertOnSubmit
If we correctly understood you, you want to be able to work with the new data for your table without sending it to the database (SubmitChanges() method), is it so?
This is the expected behavior: the query result is based mainly on the rows returned by the server; the LinqConnect runtime does not search for the suitable entities in the entity cache or among the entities marked for insertion.
Thus, in order to changes take effect and were sent to the database, you should call the SubmitChanges() method for your DataContext. The InsertOnSubmit() method assumes that all changes will be made on calling the SubmitChanges() method.
Please add the following line to your code:after
For more information please refer to:
http://www.devart.com/linqconnect/docs/ ... ubmit.html
http://www.devart.com/linqconnect/docs/ ... anges.html
This is the expected behavior: the query result is based mainly on the rows returned by the server; the LinqConnect runtime does not search for the suitable entities in the entity cache or among the entities marked for insertion.
Thus, in order to changes take effect and were sent to the database, you should call the SubmitChanges() method for your DataContext. The InsertOnSubmit() method assumes that all changes will be made on calling the SubmitChanges() method.
Please add the following line to your code:
Code: Select all
Сontext.SubmitChanges();
Code: Select all
ls.InsertOnSubmit(vs);
http://www.devart.com/linqconnect/docs/ ... ubmit.html
http://www.devart.com/linqconnect/docs/ ... anges.html
Re: InsertOnSubmit
Thank you, I understand. But I would like to be able to work with new records before they are sent to the database in an off-line context - is there any way to do that?
/Glenn
/Glenn
Re: InsertOnSubmit
The only way to access the new data before inserting them into the database - is to use DataContext.GetChangeSet() method.
Please refer to:
http://www.devart.com/linqconnect/docs/ ... geSet.html
http://msdn.microsoft.com/en-us/library ... geset.aspx
Please refer to:
http://www.devart.com/linqconnect/docs/ ... geSet.html
http://msdn.microsoft.com/en-us/library ... geset.aspx