none
How to create dynamic linq to entity especiallywhen number of col can change RRS feed

  • Question

  • Dear all

    I was trying to create dynamic query in linq to entity.( i am using 2012 and sqlserver 2005)

    Following are the details.
     
    create table t1(t1id int, col1 datetime, col2 varchar(500),col3 int)

    There are following cases.

    1)Columns of select and where clause can change.

    2)Columns of select , where and group by can change.

    Example:

    1)Select col1,col2 from t1 where col3 = 1 and co1 between '01 jan 2009' and '31 dec 2013'


    2)Select col1,count(col2) from t1 where col3 = 1 and co11 between '01 jan 2009' and '31 dec 2013'
    group by co11

    -- And i would like to formulate above as follows in 2012(linq to entity)

    " select "+ @selectclause + " from t1  where " + whereclause


    yours sincerely

    Monday, December 23, 2013 10:00 AM

Answers

  • Hello,

    >>I was trying to create dynamic query in linq to entity.( i am using 2012 and sqlserver 2005)

    For this, I think this is what you want - LINQ Dynamic Query Library:

    http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

    LINQ (language integrated query) is one of the new features provided with VS 2008 and .NET 3.5.  LINQ makes the concept of querying data a first class programming concept in .NET, and enables you to efficiently express queries in your programming language of choice.

    One of the benefits of LINQ is that it enables you to write type-safe queries in VB and C#.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 24, 2013 2:50 AM
    Moderator

All replies

  • Hello,

    >>I was trying to create dynamic query in linq to entity.( i am using 2012 and sqlserver 2005)

    For this, I think this is what you want - LINQ Dynamic Query Library:

    http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

    LINQ (language integrated query) is one of the new features provided with VS 2008 and .NET 3.5.  LINQ makes the concept of querying data a first class programming concept in .NET, and enables you to efficiently express queries in your programming language of choice.

    One of the benefits of LINQ is that it enables you to write type-safe queries in VB and C#.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 24, 2013 2:50 AM
    Moderator
  • i would like to confirm that my problem can not be implemented or can not be impletmented in linq to entity?

    yours sincerely

    Tuesday, December 24, 2013 5:13 AM
  • Hi,

    >>i would like to confirm that my problem can not be implemented or can not be impletmented in linq to entity?

    What does it mean? The link I provided is already used linq to entities. 

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 24, 2013 5:20 AM
    Moderator
  • i have one doubt can i use System.Linq.Expressions

    in place of above dll , which u have mentioned , because one has to add the external library

    please tel me which one is better?

    yours sincerely


    • Edited by rajemessage Sunday, January 5, 2014 2:04 PM
    Thursday, January 2, 2014 12:55 PM