var ur = os.Extent<UserRole>().SingleOrDefault(c =>c.UserID == id);
VS2008 tell me that this expression is obsolete, why,- and what should replace it?
(it compile and execute just fine)
2 Answers, 1 is accepted
0
Thomas
Telerik team
answered on 14 Apr 2009, 08:58 AM
Hello Hessner,
the obsolete warning is used in this case to notify you that the given expression is not executed on the server side, but on the client, which could have a performance impact.
The better way to express the query is like follows:
var ur = os.Extent<UserRole>().Where(c => c.UserID == id).SingleOrDefault();
The reason for this behavior is that we currently do not push down the filter expression of SingleOrDefault as an additional Where expression; a future release will do this correctly and then the obsolete warning will be gone.
Best wishes,
Thomas
the Telerik team
Check out
Telerik Trainer
, the state of the art learning tool for Telerik products.