This is a migrated thread and some comments may be shown as answers.

Obsolete?

2 Answers 86 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hessner
Top achievements
Rank 2
Hessner asked on 10 Apr 2009, 02:03 PM
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

Sort by
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.
0
Hessner
Top achievements
Rank 2
answered on 14 Apr 2009, 02:28 PM
Thank you, for the explanation.
Tags
LINQ (LINQ specific questions)
Asked by
Hessner
Top achievements
Rank 2
Answers by
Thomas
Telerik team
Hessner
Top achievements
Rank 2
Share this question
or