Is LINQ dynamic possible to dynamically specify a from clause?

I want to create dynamic linq.

But I want to dynamically set the table (from the sentence)

Is it possible?

Malcolm

+3
source share
3 answers

As always, it depends: -p

If you want to use LINQ extension methods or query syntax, then no: this is closely related to IQueryable<T>where Tis the source type. Depending on the scenario, there may be an option as a whole:

public IQueryable<T> Get<T>(int id) where T : SomeBaseClass
{
    return GetData<T>().Where(row=>row.SomeProp == id);
}

LINQ-to-SQL, , GetTable<T>() ( ). , , (MakeGenericMethod) - !

?

, , ... , , ExecuteQuery, string .

+1

, porsible, SQL (), , , , ( ). Linq string anyware, , - , , Linq , . :)

, , os , , :)

0

LINK SQL.

, SQL Server LINQ-To-SQL, LINQ SQL - .

, LINQ , . SQL.

0

Source: https://habr.com/ru/post/1702521/


All Articles