AddOptional<tblObject>(x =>x.Title, objectToSend.SupplementaryData);
private static void AddOptional<TType>(Expression<Func<TType,string>> expr, Dictionary<string, string> dictionary)
{
string propertyName;
string propertyValue;
Expression expression = (Expression)expr;
while (expression.NodeType == ExpressionType.Lambd...
This relates to computed columns and default constraints (and possibly other expressions) in SQL Server 2005 (or above). Both of these use an arbitrary expression to generate a value, e.g. (year+1) for a computed column representing "next year" (this is obviously a simple and stupid example).
What I'm trying to do: I want to be able to ...
I've been looking for a good tutorial on Expression trees (C#) for a while, but no luck so far. Most of the stuff I've found on the Web was too high level and very basic.
Does anyone know some decent tutorial that goes beyond the fundamentals?
...
I want a Linq Expression which dynamically compiles at runtime
I have a value and if than value greater than say for e.g. 5000 and another value > 70 then it should return a constant x
else
value greater than say 5000 and another value < 70 it returns y
How do I create an expression tree
a > 5000 & b < 70 then d
else
a > 5000 & b >7...
Dear all,
I have the following code. I constructed an expression tree and I am stuck parsing it to find the result
You will find the details within my code
public enum OpertaionType { add, sub, div, mul}
public class Node {
public Node(Node lhs, Node rhs, OpertaionType opType, int index) {
this.lhs = lhs;
this....
I will keep it really simple,
How do I get expression tree out of lambda??
or from query expression ?
...
Okay, I have a an interface, lets call it
public interface bar {
string Foo;
}
also have a class that implements the interface
public fooBar : bar {
public string Foo {get; set;}
}
I then have a property hanging off another object that contains a list of interface "bar" that contain different implementations, like so,
pu...
I want to be able to create "Transformation" classes that take a given object, perform a series of transformations on it (i.e. change property values) and keeps track of the transformations performed. The transformation performed will vary based on the properties of the object provided.
I want to be able to apply transformation rules (...
I am working on a repository pattern where the API look as follows:
var visitor = repository.Find(x => x.EmailAddress == credentials.EmailAddress &&
x.Password == credentials.Password);
where visitor is a domain object and x represents this domain object. The method signature of the Find method on the re...
i want to create the following query in expression trees:
var test = from datarow in tempResults
where datarow.Field<String>("ColumnName") == "Column"
select datarow;
How do i create the expression : datarow.Field("ColumnName")?
i tried everything, i even got stuck on getting the MethodInfo of Fi...
I have a pair of Linq to SQL queries which contain the same complex Where clause, specifically:
where ((range.MinimumFrequency <= minFreq && minFreq <= range.MaximumFrequency)
|| (range.MinimumFrequency <= maxFreq && maxFreq <= range.MaximumFrequency)
|| (range.MinimumFrequency <= minFreq && maxFreq <= range.MaximumFrequency)
|| (range...
I've been trying to solve a little problem with VB.NET and the expression trees it likes to generate.
I have a simple test...
Public Sub ActiveRecord_Find_By_NonKey_Returns_123()
Dim orders = Order.Find(Function(item As Order) item.EmployeeID = 1)
Assert.Equal(Of Integer)(123, orders.Count)
End Sub
One would expect that to wor...
For example i got a class and its got its own properties and i am passing the name of the class and the name of the property to be called to a function
Say for example exp is the variable which i am passing which contains a value = "ClassA,Property1"
Function Property2BCalled(byval exp as String)
dim classname ...
I'm trying to use the Expression tree and Lamdba Expression objects in .Net 3.5 to allow me to dynamically calculate boolean expression entered by a user.
So far a user can create an expression tree consisting of BinarayExpressions that AND and OR values expressed as ParameterExpressions. I was then planning on creating a LambdaExpressi...
Hello,
I have C# extension methods on IQueryable, e.g. FindNewCustomers() and FindCustomersRegisteredAfter(int year) and so forth which I use to "chain" a query together for LINQ to SQL.
Now to my problem: I want to create compiled queries, e.g.:
private static Func<MyDataContext, SearchInfo, IQueryable<Customer>>
CQFindAll ...
I'm using the standard visitor pattern to iterate through a LINQ expression tree in order to generate dynamic SQL WHERE clauses.
My issue is that unlike C#, you can't use a standalone boolean expression in SQL; you have to compare it to either 1 or 0.
Given this hypothetical lambda expression:
h => h.Enabled || h.Enabled == false
It...
MSDN say:
The compiler can also build an
expression tree for you. A
compiler-generated expression tree is
always rooted in a node of type
Expression<TDelegate>; that is, its
root node represents a lambda
expression.
But what if I want to build an expression tree rooted in a node of type MethodCallExpression, BinaryExpre...
Hello,
Is it possible to ha ve a switch in a lambda expression ? IF not, why ? Resharper display it as an error.
...
Hi
I am looking for a parser that can operate on a query filter. However, I'm not quite sure of the terminology so it's proving hard work. I hope that someone can help me. I've read about 'Recursive descent parsers' but I wonder if these are for full-blown language parsers rather than the logical expression evaluation that I'm looking f...
I have several Expression<Func<User,bool>> expressions that shares properties. For example,
Expression<Func<User, bool>> e1 =
(User u) => u.IsActive && u.Group != "PROCESS" && u.Name != null;
Expression<Func<User, bool>> e2 =
(User u) => u.IsActive && u.Group != "PROCESS" && u.Name != "A";
Expression<Func<User, bool>> e3 =
(Use...