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...
Hi,
I am trying to serialize something based upon meeting particular criteria.
To this end my original hope was to use attributes containing a lambda expression on an object's properties.
However, as this cannot be done I've settled for having a Func<T,bool> member within the class and passing the type (or first parameter type) and na...
To my knowledge, combined with the knowledge of others, among the mainstream languages
Objective C
C#
VB.net
Java
Python
Ruby
Javascript
Lisp
Perl
have closures and anonymous functions. Plain C/C++ doesn't have either of those.
Do closures in these languages have the same semantics? How important are they for everyday programming?
...
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...
Hi,
I just started playing with lambdas and Linq expression for self learning. I took the simple factorial problem for this. with the little complex scenario where find the factorial for given n numbers (witout using recursive loops).
Below the code i tried. But this is not working.
public void FindFactorial(int range)
{
var res...
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...
Hey there.
I'm searching for a way to auto compare an object propriety to a list of values inside a lambda expression.
For example i have this lambda expression:
List<MyObjectType> myObjectList = GetObjectValues();
List<MyObjectType> filterdObjectList = myObjectList.Where(x => x.objectProp == ??a list of values??)
Basicly I need to ...
Hello,
Is it possible to ha ve a switch in a lambda expression ? IF not, why ? Resharper display it as an error.
...
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...
Is it possible to create a list of anonymous delegates in C#? Here is code I would love to write but it doesn't compile:
Action<int> method;
List<method> operations = new List<method>();
...
Lets say we need to select two sets from a table: "Things"
var GradeA = db.Things.Where(t=> condition1);
var GradeB = db.Things.Where(t=> !condition1 && condition2);
var DesiredList = GradeA.union(GradeB);
alternatively, we need to write a single statement to avoid union cost:
var DesiredList = db.Things.Where(t=> condtion1 || (!con...
I appreciate that similar questions have been asked before, but I am struggling to invoke the Linq Where method in the following code. I am looking to use reflection to dynamically call this method and also dynamically build the delegate (or lambda) used in the Where clause. This is a short code sample that, once working, will help to fo...
There is no IdentityEqual item in ExpressionType enumeration. How can I construct expreesion tree with VB.NET Is operator?
...
I need to get some info passed as a lambda expression to some methods. Basically, it's a way to add information to a database query. A simple example would be:
companyData.GetAll(
where => "SomeField = @SOMEFIELD",
order => "Id",
SOMEFIELD => new Parameter {DbType = DbType.String, Value = "some value"}
)
It's working pretty w...
Just a little niggle about LINQ syntax. I'm flattening an IEnumerable<IEnumerable<T>> with SelectMany(x => x).
My problem is with the lambda expression x => x. It looks a bit ugly. Is there some static 'identity function' object that I can use instead of x => x? Something like SelectMany(IdentityFunction)?
...
I would like to use the lambda expression in my Repository
as a generic parameter. If I use a firm like this one:
MyEntity entity:null
void Run(Expression<Func<MyEntity ,bool>> expression)
I can call it in this way:
Run(x => x.FirstName = "Whatever")
What I would like is the ability to do something like this:
Run(x => x.FirstName...
Hi,
I thought the following two were equivalent:
named_scope :admin, lambda { |company_id| {:conditions => ['company_id = ?', company_id]} }
named_scope :admin, lambda do |company_id|
{:conditions => ['company_id = ?', company_id]}
end
but Ruby is complaining:
ArgumentError: tried to create Proc object without a block
Any idea...
I am learning lambda calculus but I cant seem to understand the encoding for the number 0.
how is "function that takes in a function and a second value and applies the function zero times on the argument" a zero? Is there any other way to encode zero? Could anyone here help me encode 0?
...
I have two variables of type ILookup. I wanted to use Union or Concat to combine their values and assign the result to a third variable of the same type. Both Union and Concat return IGrouping. It must be dead simple to convert IGrouping to the ILookup but I just can't do it!!! :-( IGrouping exposes just the Key so I am struggling with...
How would you translate the following generic Lambda function into a lambda expression :
context.AssociateWith<Product>(p => p.Regions.Where(r => r.Country == 'Canada')
I'm trying to create a full lambda expression without any <T> or direct call. Something like :
void AddFilter(ITable table, MetaDataMember relation)
{
var table...