Building dynamic linq queries involving lookup column in where clause using Entity List
Dynamic query is being built using expression builders. This is working for all columns except columns of type Lookup.
If a string value is passed to the LookUp column where condition, linq query itself throws error saying “No coercion operator is defined between types 'System.String' and 'EmpTyeItem'. EmpType is a lookup column.
Please let us know if any solution for this
privateIQueryable<EntityLISTItem> AddWhere(IQueryable< EntityLISTItem > query, string sSearchVal){
foreach (string strSingleSearch in strMultiSear){
filter.Add(new Filter(strField, Op.Equals, strValue)); // filter is a custom class which builds expressions
}
query = query.Where(ExpressionBuilder.GetExpression< EntityLISTItem >(filter)); //all filter expressions are passed to get the complete query
}
So I tried changing the value passed to GrantTypeItem type. Now the linq qyery is formed properly.But when it executes I get error “The query uses unsupported elements, such as references to more than one list, or the projection of a complete entity by using EntityRef/EntitySet. “
Marulasiddappa SB (Swamy)
No comments:
Post a Comment