Converting Expression to String

This may not be the best/most efficient method, but it does work. Expression<Func<Product, bool>> exp = (x) => (x.Id > 5 && x.Warranty != false); string expBody = ((LambdaExpression)exp).Body.ToString(); // Gives: ((x.Id > 5) AndAlso (x.Warranty != False)) var paramName = exp.Parameters[0].Name; var paramTypeName = exp.Parameters[0].Type.Name; // You could easily add “OrElse” and others… expBody … Read more

LINQ : Dynamic select

You can do this by dynamically creating the lambda you pass to Select: Func<Data,Data> CreateNewStatement( string fields ) { // input parameter “o” var xParameter = Expression.Parameter( typeof( Data ), “o” ); // new statement “new Data()” var xNew = Expression.New( typeof( Data ) ); // create initializers var bindings = fields.Split( ‘,’ ).Select( o … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)