c# - Only parameterless constructors and initializers are supported in LINQ to Entities -


while trying sem-complex query display listview content on page got stuck on famous "only parameterless contstructor , initializers supported in linq entities" error.

here code used ... can't find place initialized inside query parameters ....

protected void artistslist() {     guid cat1 = new guid("916ec8ae-8336-43b1-87c0-8536b2676560");     guid cat2 = new guid("92f2a07f-0570-4521-870a-bf898d1e92d6");      var memberorders = (from o in datacontext.orderset                         o.status == 1 || o.status == 0                         select o.id);      var memberorderdetails = (from o in datacontext.orderdetailset                               memberorders.any(f => f == o.order.id)                               select o.product.id );      var inventoryitems = (from in datacontext.inventoryitemset                           select i.inventory.product.id);      var products = (from p in datacontext.productset                     join m in datacontext.contactset on p.manufacturerid equals m.id                     p.active == true                        && p.showonwebsite == true                        && p.category.id != cat1                        && p.category.id != cat2                        && p.availabledate <= datetime.today                        && (p.discontinuationdate == null || p.discontinuationdate >= datetime.today)                        && memberorderdetails.any(f => f != p.id)                        && inventoryitems.any(f => f == p.id)                     select new { contactid = m.id, contactname = m.name });      artistsrepeater.datasource = products;     artistsrepeater.databind();      response.write("product count: " + products.count()); } 

the error pops on line artistsrepeater.datasource = products;

i tried comment lines && memberorderdetails.any(f => f != p.id) , && inventoryitems.any(f => f == p.id) , still doesn't change anything

any hints ?

[edit]

with linqpad, works join bugging on commented line

(from p in products join m in members on p.manufacturerid.value equals m.id p.active == true && p.showonwebsite == true && p.availabledate <= datetime.today && (p.discontinuationdate == null || p.discontinuationdate >= datetime.today) //&& (from od in memberorderdetails (from mo in memberorders mo.status == 1 || mo.status == 0 select mo.id).any(f => f == od.id) select od.product.id) && (from inv in inventoryitems select inv.inventory.productid).any(i => i.value == p.id) select m).distinct() 

[edit-2]

it seems query in linqpad ok :

(from p in products join m in members on p.manufacturerid.value equals m.id p.active == true && p.showonwebsite == true && p.availabledate <= datetime.today && (p.discontinuationdate == null || p.discontinuationdate >= datetime.today) && !(from od in memberorderdetails (from mo in memberorders mo.status == 1 || mo.status == 0 select mo).any(f => f.id == od.id) select od.product.id).any(i => == p.id) && (from inv in inventoryitems select inv.inventory.productid).any(i => i.value == p.id)  select m) 

ok, subtle, if change linqpad query from:

           (from p in products             join m in members                  on p.manufacturerid.value equals m.id             p.active == true                 && p.showonwebsite == true                 && p.availabledate <= datetime.today                 && (p.discontinuationdate == null || p.discontinuationdate >= datetime.today)                 && (from od in memberorderdetails                      (from mo in memberorders                             mo.status == 1 || mo.status == 0                             select mo.id).any(f => f == od.id)                      select od.product.id)                 && (from inv in inventoryitems                      select inv.inventory.productid).any(i => i.value == p.id) 

...to:

           (from p in products             join m in members                  on p.manufacturerid.value equals m.id             p.active == true                 && p.showonwebsite == true                 && p.availabledate <= datetime.today                 && (p.discontinuationdate == null || p.discontinuationdate >= datetime.today)                 && (from od in memberorderdetails                      (from mo in memberorders                             mo.status == 1 || mo.status == 0                             select mo).any(f => f.id == od.id)          // note!                     select od.product.id)                 && (from inv in inventoryitems                      select inv.inventory.productid).any(i => i.value == p.id) 

why? think type inference might doing wrong here. i've seen similar thing datetimes.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -