Say Table1 - a table with two columns. Table 1ID and name.
If I do the following code ...
var Obj1 = new Table1(); Obj1.Name = "hello" TestDBEntities.AddToTable1(Obj1); var currObj = Table1.Where(o => o.Name.Contains("hello")).FirstOrDefault();
currObj will return null.
But if I do it
var Obj1 = new Table1(); Obj1.Name = "hello" TestDBEntities.AddToTable1(Obj1); **TestDBEntitles.SaveChanges();** var currObj = Table1.Where(o => o.Name.Contains("hello")).FirstOrDefault();
Then currObj will return the first object I created. This is because this object is in the database.
I am creating a large batch process and I do not want to keep everything in the database until the end. However, I have to do checks, such as making sure that a certain object has not yet been added, etc., which require me to reference these objects before they are stored in the database.
Is it possible to make LINQ queries in the Entity Framework that can be aware of objects that are in memory that were not stored in the database.
source share