LINQ "scope.Extent"

14 posts, 1 answers
  1. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 22 Dec 2008 Link to this post

    Hi,

    Still learning ....

    Everyone seems to be talking about a scope.Extent object when talking about LINQ, but how do I get this object?

    I have:

    using (IObjectScope scope = Database.Get(_session.ConnectionId).GetObjectScope())  
                {  
    // "scope.Extent" does not exist!  
                } 

    ... but the scope object does not return a .Extent property. Do I need to cast the IObjectScope out to something else?
  2. Answer
    Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 22 Dec 2008 Link to this post

    Hi Nathan,

    "Extent" is an extension method for using the OpenAccess scope in Linq queries. If you want to enable it, include the "Telerik.OpenAccess.Query" namespace.

    Greetings,
    Alexander
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 23 Dec 2008 Link to this post

    That's got it, thanks Alexander.
  5. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 23 Dec 2008 Link to this post

    By the way, had 2 glowing Tweets sent to me yesterday about your service on Twitter when I said I was working with Telerik/OpenAccess.

  6. Simon
    Simon avatar
    5 posts
    Member since:
    Jul 2010

    Posted 14 Jul 2010 Link to this post

    Hi, I'm having the same problem: The Extent method doesn't exist on IObjectScope.

    After reading this thread, I tried adding a line

     using Telerik.OpenAccess.Query;

     

     

    but that in turn gives me another error

    Error 19 Using the generic type 'Telerik.OpenAccess.Query<T>' requires 1 type

    Am I missing something else?

  7. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 14 Jul 2010 Link to this post

    Hi Simon,
    The using is not necessary but you have to add a reference to Telerik.OpenAccess.35.Extensions.dll.

    Sincerely yours,
    Jan Blessenohl
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Simon
    Simon avatar
    5 posts
    Member since:
    Jul 2010

    Posted 14 Jul 2010 Link to this post

    Thanks Jan, but I'm afraid I already have that reference.

    I've attached a screenshot that shows project refs and the intellisense window on the interface.

    ??
  9. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 14 Jul 2010 Link to this post

    Hi Simon,
    Ah, now I see it, it is in the Telerik.OpenAccess namespace. You have to add a using for that.

    Kind regards,
    Jan Blessenohl
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Simon
    Simon avatar
    5 posts
    Member since:
    Jul 2010

    Posted 14 Jul 2010 Link to this post

    That worked, thanks Jan
  11. Bassel
    Bassel avatar
    7 posts
    Member since:
    Nov 2008

    Posted 06 Feb 2011 Link to this post

    Hi

    I still can't get the scope thing
    I've add
    using Telerik.OpenAccess.Query;
    but how can I get the scope object itself??
  12. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 07 Feb 2011 Link to this post

    Hi Bassel,

    In the latest versions of Telerik OpenAccess the Telerik.OpenAccess.Query namespace is no longer needed in order to use the Extent<T> method. The method is now part of the root Telerik.OpenAccess namespace.

    Could you please tell us which of the OpenAccess approaches you are using - the "classic" Forward/Reverse mapping wizards or the new visual designer? If you are using the new designer, you will have to use the auto-generated OpenAccessContext class to manage persistent objects instead of an object scope. Please try to give some more details on what you are trying to achieve, so we can help you further.

    All the best,
    Alexander
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  13. Bassel
    Bassel avatar
    7 posts
    Member since:
    Nov 2008

    Posted 07 Feb 2011 Link to this post

    Hi

    thanks for the help
    I think you've already answered me, coz I'm using the new visual designer

    thnx
  14. Gopinath
    Gopinath avatar
    21 posts
    Member since:
    Dec 2011

    Posted 24 Jan 2012 Link to this post

    Hello,

    when I use this statement:

    scope.extent<ObjectName>().where(<condition for filter>)

    Does it brings all the records from the table and then does the filter or it just retreives only filtered records from the DB.

    Pls. advise.
  15. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 24 Jan 2012 Link to this post

    Hello,

    when you use

    Scope.Extent<Type>().Where(ConditionLambda)

    nothing happens. This is because LINQ is evaulated lazily, which means, that you have to obtain the values from the IQueryable<Type> that you defined. When you do so (most likely by issuing .GetEnumerator() on that query instance), the complete expression tree  - that is only known then - will be inspected and transformed. In the case of the query as given above, OpenAccess will push the ConditionLambda expression as filter to a SQL query, and only the filtered instances will be brought from the server to the client memory.

    Thomas
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Back to Top
DevCraft banner