If someone is very popular with the Linq.Dynamic namespace, I could use some help - I could not find any independent resources on the Internet.
I mainly use DynamicExpression.ParseLambda to create an expression when the type is not known at compile time,
public Expression GetExpression(Type t, List<QueryFilter> filters) { // pseudo code // extracts a string representation of the query as 'expressionString' return DynamicExpression.ParseLambda(t, typeof(Boolean), expressionString, values); }
Where is the QueryFilter:
public class QueryFilter { string propertyName; ExpressionType operationType; object value; }
What is a simple binary function like "Age> 15" or something like that.
This is how the GetExpression function works, it takes two types: input type and output type, and ultimately generates what is usually created using the Func delegate. It also takes a string representing the query and the params [] object of the values, which are respectively the expressions and expressions of 'expressionString'.
However, I am unable to execute the dynamic expression in LINQ-to-SQL using the DataContext generated from the SqlMetal file (.dbmc).
DatabaseContext db = new DatabaseContext(connectionString); var filter = DynamicExpressionBuilder. GetExpression(typeof(SysEventLogT), sysEventFilters) var query = db.SysEventLogT.Where(filter);
It produces the following error:
System.Data.Linq.Table<DBReporting.Linq.Data.SysEventLogT>
no definition of "where" and best method of overloading
System.Linq.Dynamic.DynamicQueryable.Where<T>(System.Linq.IQueryable<T>, string, params object[])
has some invalid arguments.
I know that my DataContext instance really treats sql tables as properties ... do I need to somehow think with GetProperty () for this to work? Or maybe I need to create something else. Where is the extension?