I'm trying to do a LINQ query against EntitiesV2.Product to find all products which have a "Discount" property defined. I have the following statement:
var q = from prod in Product.All() join prop in ProductProperty.All() on prod.ProductId equals prop.ProductId join field in ProductDefinitionField.All() on prop.ProductDefinitionFieldId equals field.ProductDefinitionFieldId where field.Name == "Discount" && prop.Value == "My Brand" && prod.ParentProductId == null select prod;
If you can you should hold off using V2 as there will be missing properties like the one you just found due to the fact that we're primarily using it for performance internally. Queries created against V1 and V2 will exhibit the same level of performance though.
I switched to using V2 as I was (and having switched back to V1, still am) getting page load times of 5/7 seconds which are pretty much instant with V2.
Does that mean I can't use V2 for this? as I have all other queries I need working with V2.
Selecting discounted products via LINQ?
Hi Guys,
I'm trying to do a LINQ query against EntitiesV2.Product to find all products which have a "Discount" property defined. I have the following statement:
Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [.Where(.Select(NHibernate.Linq.NhQueryable`1[UCommerce.EntitiesV2.Product], Quote((entity) => (entity))), Quote((x) => (String.op_Inequality(.FirstOrDefault(.Where(x.ProductProperties, (y) => (String.op_Equality(y.ProductDefinitionField.Name, p1)))).Value, p2))))]
Anybody got any ideas what this might be? And how I can do this query?
Many thanks
Matt
How about something like this
var q = from prod in Product.All()
join prop in ProductProperty.All() on prod.ProductId equals prop.ProductId
join field in ProductDefinitionField.All() on prop.ProductDefinitionFieldId equals field.ProductDefinitionFieldId
where field.Name == "Discount" && prop.Value == "My Brand" && prod.ParentProductId == null
select prod;
I'm now getting:
could not resolve property: ProductId of: UCommerce.EntitiesV2.ProductProperty [.Select(.Where(.Join(.Join(NHibernate.Linq.NhQueryable`1[UCommerce.EntitiesV2.Product], NHibernate.Linq.NhQueryable`1[UCommerce.EntitiesV2.ProductProperty], Quote((prod) => (prod.ProductId)), Quote((prop) => (prop.ProductId)), Quote((prod, prop) => (new <>f__AnonymousType0`2(prod, prop)))), NHibernate.Linq.NhQueryable`1[UCommerce.EntitiesV2.ProductDefinitionField], Quote((<>h__TransparentIdentifier0) => (<>h__TransparentIdentifier0.prop.ProductDefinitionFieldId)), Quote((field) => (field.ProductDefinitionFieldId)), Quote((<>h__TransparentIdentifier0, field) => (new <>f__AnonymousType1`2(<>h__TransparentIdentifier0, field)))), Quote((<>h__TransparentIdentifier1) => (AndAlso(AndAlso(String.op_Equality(<>h__TransparentIdentifier1.field.Name, p1), String.op_Inequality(<>h__TransparentIdentifier1.<>h__TransparentIdentifier0.prop.Value, p2)), Equal(<>h__TransparentIdentifier1.<>h__TransparentIdentifier0.prod.ParentProductId, p3))))), Quote((<>h__TransparentIdentifier1) => (<>h__TransparentIdentifier1.<>h__TransparentIdentifier0.prod)))]
The code was only tested for UCommerce.Entities.
If you can you should hold off using V2 as there will be missing properties like the one you just found due to the fact that we're primarily using it for performance internally. Queries created against V1 and V2 will exhibit the same level of performance though.
I switched to using V2 as I was (and having switched back to V1, still am) getting page load times of 5/7 seconds which are pretty much instant with V2.
Does that mean I can't use V2 for this? as I have all other queries I need working with V2.
Matt
I need to add support for your query. It's pretty straightforward though so I'll see if I can have a release ready for you later today.
Cool, thanks Soren. I really appreciate it.
Matt
is working on a reply...