LINQ-to-SQL and extension method in subQuery

My extension method:

public static IEnumerable<T> FilterCultureSubQuery<T>(this Table<T> t)
    where T : class
    {
      return t;
    }

I tried using it in this query

var test = from p in t.Products
             select new
             {
               Allo = p,
               Allo2 = (from pl in t.ProductLocales.FilterCultureSubQuery()
                        select pl)
             };

What should be the signature of my method extension? I always get this error:

Method 'System.Collections.Generic.IEnumerable`1 [ProductLocale] FilterCultureSubQuery [ProductLocale] (System.Data.Linq.Table`1 [ProductLocale])' has no supported translation to SQL.

I also tried this signature:

public static IQueryable<T> FilterCultureSubQuery<T>(this Table<T> t)
    where T : class
    {
      return t;
    }

And I got this error:

Method 'System.Linq.IQueryable`1 [ProductLocale] FilterCultureSubQuery [ProductLocale] (System.Data.Linq.Table`1 [ProductLocale])' has no supported translation to SQL.

thanks

+3
source share
3 answers

, , , . ?

var test = from pl in t.ProductLocales.FilterCultureSubQuery()  select pl;

var test = from p in t.Products
           select new
           {
             Allo = p,
             Allo2 = (from pl in t.ProductLocales.FilterCultureSubQuery()
                      select pl)
           }; 

.

var test = (from p in t.Products
               select new
               {
                 Allo = p,
                 Allo2 = (from pl in t.ProductLocales.FilterCultureSubQuery()
                          select pl)
               }).ArrangeExpression(); 

LINQ-TO-SQL . rewrite, .

?

+1

. , , , " SQL".

DLINQ SQL, . .

Where.

+4

.

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

, , .

+2
source

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


All Articles