Obsolete?

3 posts, 0 answers
  1. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 10 Apr 2009 Link to this post

    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. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 14 Apr 2009 Link to this post

    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.
  3. DevCraft banner
  4. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 14 Apr 2009 Link to this post

    Thank you, for the explanation.
Back to Top