I insert a new object into LINQ-to-SQL DataContext without calling SubmitChanges() yet:
MyDataContext db = new MyDataContext();
MyObject newObject = new MyOb
Try:
db.MyObjects.SingleOrDefault(o => o.Id == 1);
You'd think this would be the same, but see these two connect issues:
If that doesn't work, I know that the .Single(o => o.Id == 1)
works in 3.5 SP1 (I don't know if I tried .SingleOrDefault(pred)
). Apparently the .Where(o => o.Id == 1).Single()
is fixed in 4.0 - again, I haven't tried .Where(pred).SingleOrDefault()
.