Dynamic Linq Query Part 2

6 posts, 0 answers
  1. Kyle Pietschmann
    Kyle Pietschmann avatar
    3 posts
    Member since:
    Jan 2010

    Posted 14 Jan 2010 Link to this post

    I saw the other thread entitled "Dynamic Linq" (http://www.telerik.com/community/forums/orm/linq-questions/dynamic-linq.aspx), but the syntax just did not work for me.  When I try a where(), there is no overloaded version that takes a string parameter.  Am I missing a reference?

    This is how our queries are formatted, and they do work:

    IObjectScope

     

    scope = ProfitabilityScopeProvider.ObjectScope();

     

     

     

    var branchItems = from basedata in scope.Extent<Ge.Wf.Profitability.Data.BaseData>()

     

     

    where basedata.BranchNumber == 1234

     

     

    select basedata;

    But I'd like to use a string for the where clause for more dynamic queries, like is sampled in the examples in the link above.  I tried to modify my query to look like the example from Alexander (of Telerik), but the parameters expected by the where() always include something called a Linq Expressions Predicate.  What do I need to do to make the following work?  Or better yet, in the format above, but with a string for the where clause.

    var branchItems = scope.Extent<Ge.Wf.Profitability.Data.BaseData>()
    .Where("basedata.Branchname == @0", 1234);

     

  2. Kyle Pietschmann
    Kyle Pietschmann avatar
    3 posts
    Member since:
    Jan 2010

    Posted 14 Jan 2010 Link to this post

    Got it.  For others who don't realize, you have to download the sample here:
    http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

    You then take the Dynamic.cs file from the sample and simply add it to your project.  Put

    using

     

    System.Linq.Dynamic;  at the top of the module and off you go.

     

  3. DevCraft banner
  4. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 15 Jan 2010 Link to this post

    Hello Kyle Pietschmann,

    I am glad to see that you have found the solution. We are going to publish soon a Code Library project demonstrating the Dynamic Linq integration with OpenAccess. We will notify you in this thread once it is uploaded.

    Best wishes,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Bernhard
    Bernhard avatar
    8 posts
    Member since:
    Apr 2009

    Posted 19 Mar 2010 Link to this post

    Hello Alexander,

    when do you think could you publish a Code Library project demonstrating the Dynamic Linq integration with OpenAccess?

    Thanks & Best regards
    Bernhard


  6. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 25 Mar 2010 Link to this post

    Hi Bernhard,

    I am sorry for the delay of this example, we were really occupied with the preparation of the Q1 version but since it is released now we have a bit more time to invest in examples. You can expect this demo to be available next week. Thank you for your patience.

    Sincerely yours,
    Alexander
    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.
  7. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 26 Mar 2010 Link to this post

    Hi Bernhard,

    The sample is done and uploaded to our Code library. You can download it from here. Note that you need to install the latest OpenAccess version (Q1 2010) in order to run it. Hope that helps.

    Sincerely yours,
    Alexander
    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.
Back to Top
DevCraft banner