Hi
Is it possible to implement a ! (not) using expression trees. I'm interested in creating a c# eval class which will parse and evaluate logical expressions which contain true, false, ||, && and !. I know that && and || are currently supported by .NET 4 expression trees, but I was wondering if their is a way to implement summat like !...
i have a method that takes as a parameter an expression because I need the method string name, and I don't care about the parameters of that method, is it possible to do that ?
...
What I'd like to do:
1. Create an arbitrary LINQ query based on user-selected criteria that will
2. Query against a proxy collection (facade) that
3. Converts the query to NHibernate DetachedCriteria and serializes OR just serializes the LINQ expression and then
4. Sends the serialized query to the server via WCF, where
5. The service im...
Whilst creating an inline ANTLR Tree Grammar interpreter I have come across an issue regarding the multiplicity of procedure call arguments.
Consider the following (faulty) tree grammar definition.
procedureCallStatement
: ^(PROCEDURECALL procedureName=NAME arguments=expression*)
{
if(procedureName.equals("foo...
So I have a delegate which points to some function which I don't actually know about when I first create the delegate object. The object is set to some function later.
I also then want to make an expression tree that invokes the delegate with an argument (for this question's sake the argument can be 5). This is the bit I'm struggling wi...
I have a hashing method whose operations depend on input to the function. Profiling the program has shown that too much time is spent evaluating this hash method. I want to try changing it into an expression tree, so the inner loop checks can be done once. Hopefully it will be faster, but I'll learn about expression trees either way.
He...
I have a function which creates a different type of expression depending on the value of the variable passed in.
Protected Function BuildSortPredicate(ByVal tableType As Object, ByRef expr As Expression)
Dim sortExpression As Expression
If tableType Is "Job" Then
sortExpression = Expression.Lambda(Of Func(Of Job, String)...
By using Stack data structure, we can easily convert "Infix to Postfix" and "infix to Prefix" but I can't convert Prefix to postfix.
yes, we can convert prefix to infix then infix to postfix. but I want direct conversion from prefix to postfix.
Is there any feasible solution (not expression tree) ?
...
Previous questions have asked if it is possible to turn compiled delegates into expression trees, for example:
http://stackoverflow.com/questions/767733/converting-a-net-funct-to-a-net-expressionfunct
The sane answers at the time were:
It's possible, but very hard and there's no standard library solution.
Use Reflector!
But fortu...
I have an Expression<Func<T,DateTime>> I want to take the DateTime part of the expression and pull the Month off of it. So I would be turning it into a Expression<Func<T,int>> I'm not really sure how to do this. I looked at the ExpressionTree Visitor but I can't get it to work like I need. Here is an example of the DateTime Expression
...
Hi,
I wrote a custom ordering LINQ extension method as below but I think it can be optimized for large results.
Here is the code :
public static IEnumerable<T> OrderByAncesty<T>(this IEnumerable<T> source, Func<T, DateTime> dateSelector, Func<T, float> scoreSelector)
{
var original = source.ToList();
var maxDat...
I am missing the obvious: How do I access the value of a parameter inside a lambda expression expression tree?
Scenario: For a delegate x I dynamically create a lambda expression with an expression tree body which has the same signature as the delegate x. Inside the lamdba's body, I do some validation, checking, logging stuff (this is ...
Hello everybody!
Implemented a generic repository with several Methods. One of those is this:
public IEnumerable<T> Find(Expression<Func<T, bool>> where)
{
return _objectSet.Where(where);
}
Given <T> to be <Culture> it is easy to call this like this:
Expression<Func<Culture, bool>> whereClause = c => c.Cu...
Following this post: link text I'm trying to create an expression tree that references the property of a property. My code looks like this:
public interface IFoo
{
void X {get;set;}
}
public interface IBar : IFoo
{
void Y {get;set;}
}
public interface IFooBarContainer
{
IBar Bar {get;set;}
}
public class Filterer
{
/...
I'm trying to build an expression tree (still) but getting further! I need to create a BinaryExpression to perform an 'In' comparison between a Member and a collection of items. Hence, the expression should return true if the member is contained within the items.
This obviously does not exist:
Expression.MakeBinary(ExpressionType.In, m...
Update
Thanks to Marc's help the AlphaPagedList class is now available on CodePlex if anyone is interested
Original
I'm trying to create an expression tree to return elements that start with a given charecter.
IList<char> chars = new List<char>{'a','b'};
IQueryable<Dept>Depts.Where(x=> chars.Contains(x.DeptName[0]));
I want this to...
Hi all, I am not an Expression Tree master by any stretch of the imagination, what I have is code that looks like this:
int external = 10;
using(var session = new Session())
{
session.Add(new Product { Name = "test1", Price = 20 });
session.Add(new Product {Name = "test", Price = 10});
var product = sess...
My understanding of expression tree is :
Expression trees are in-memory representation of expression like arithmetic or boolean expression.The expressions are stored into the parsed tree.so we can easily transalate into any other language.
Linq to SQL uses expression tree.Normally in LINQ to SQL query the compiler translates it into pa...
Hi.
We have issues within an application using a state machine. The application is implemented as a windows service and is iteration based (it "foreaches" itself through everything) and there are myriads of instances being processed by the state machine.
As I'm reading the MEAP version of Jon Skeets book "C# in Depth, 2nd ed", I'm won...
Is there a method call in Linq that will apply a expression tree directly on a List<V>? For instance, if I have a expression tree that is built on Order type, and i have a collection of List<Order> items on which i need to apply this expression.
I am looking something similar to:
class OrderListStore : IQueryable<V>,
<other interfa...