lambda

VB9 New thread with multiple parameters

I'm trying to create a new thread and send multiple parameters as well as a delegate to report back. In VB8 I always hate to do this because it requires either introducing a new class/structure or a delegate. Is there any better way to do this in VB9 ? I'm looking for a solution something like this : Dim Th As New Thread(AddressO...

Advanced level VB.NET Book Recommendation with good Lambda Expressions and LINQ chapters

I'm looking for an advanced level VB.NET book which covers LINQ and Lambda Expressions. Generally I read C# .NET books due to lack of good VB.NET books when it comes to generic .NET Framework related subjects. However Lambda and LINQ is quite different in C# and VB.NET I'm looking for an advanced level VB.NET book on this subject. Any ...

Python Lambda - why?

I'm just beginning Python and ran head first into Lambda- which took me a while to figure out. Is lambda one of those 'interesting' language items that in real life should be forgotten? I'm sure there are some edge cases where it might be needed, but given the obscurity of it, the potential of it being redefined in future releases (my a...

How to implement outer join expression tree?

I need to implement the query using expressions syntax (because I don't know types in compile time). For example query like this one: from customer in Customers join purchase in Purchases on customer.ID equals purchase.CustomerID into outerJoin from range in outerJoin.DefaultIfEmpty() where customer.Name == "SomeName" && range.Desc...

How to 'select new' inside Linq lamda expression?

How do i do this in one statement vs breaking up in two? var newpeople= _rep.GetPeople().Where(p=>p.personID).Select(new KindoFPerson...id=p.id etc) ...

RelayCommand lambda syntax problem

I am applying the MVVM pattern per Josh Smith and having difficulty. I've been researching the problem here and can't seem to get the syntax quite right. The code below looks to me like it follows the required syntax, but Visual Studio reports error "Delegate 'System.Action' does not take '2' arguments" on the line indicated. Can some...

Recursive lambdas in F#

Take this example code (ignore it being horribly inefficient for the moment) let listToString (lst:list<'a>) = ;;' prettify fix let rec inner (lst:list<'a>) buffer = ;;' prettify fix match List.length lst with | 0 -> buffer | _ -> inner (List.tl lst) (buffer + ((List.hd lst).ToString())) inner lst "" ...

Parameter problem with Expression.Lambda()

Update: This does work, I was being stupid :( i have the following extension method public static string ExtMethod(this object self, object myparameter); at runtime this is called in any number of ways ways, i think these are all possibilities: Expression<Func<T, string>> expr = x => x.property.ExtMethod(5); Expression<Func<T, strin...

Dynamic build lambda expressions

So, I started to build a small test application to test lambda expressions. I found several examples here and elsewhere but I just don't get them. Can anybody explain my how to build an expression by using textboxes or any other variables? My Test List List<People> lPeople = new List<People> { new People {...

Lambda way to fill the value field in the ToDictionary() method?

I have two IEnumerable IEnumerable<MyObject> allowedObjects = MyService.GetAllowedObjects(); IEnumerable<MyOBject> preferedObjects = MyService.GetPreferedObjects(); We can safely assume that preferedObjects will always be a subset of allowedObjects. I want to create an IDictionary<MyObject, bool>. Objects where the key is the set of M...

Expression vs Predicate issues

I've got a bit of a challenge where I have to create an expression tree to represent a query input by the user. Since I don't have the time to create all the possible cases of user input, I figured that expression trees would aid me in solving this. For the most part, it has. I am, however, a bit stumped. I am in the code below trying t...

Implicit conversion to Func

Let's say I have an interface IMyInterface<T> that simply describes one function: public interface IMyInterface<T> { T MyFunction(T item); } I could just about replace this with Func<T, T>, but I want the interface for semantic reasons. Can I define an implicit conversion between that interface and Func<T,T> such that I could pas...

How to create a LINQ expression from an Entity Framework navigation property?

I have the following bit of code: Expression<Func<Subscription, Service>> service2= subscription => (from relationship in subscription.ChildRelationships select relationship.SecondService).FirstOrDefault(); It creates an expression that I can use later as part of a query with the entity framework. The actual code I'm using has a w...

Linq to Entity Headache

Why would the Entity framework not understand the following statement? oDestinations.Where(c => c.c_Resources.ResourceID == ID) ...

Ruby functions vs methods

In the Ruby Programming Language, Chapter 6 (second paragraph) they state: Many languages distinguish between functions, which have no associated object, and methods, which are invoked on a receiver object. Because Ruby is a purely object oriented language, all methods are true methods and are associated with at least one...

Equivalent for Python's lambda functions in Java?

Hi all, Can someone please tell me if there is an equivalent for Python's lambda functions in Java? ...

Trying to develop a new extension method

Hi, I'm using the Entity Framework and I developed this extension method: public static IQueryable<TResult> Like<TResult>(this IQueryable<TResult> query, Expression<Func<TResult, string>> field, string value) { var expression = Expression.Lambda<Func<TResult, bool>>( Expression.Call(field.Body, typeof(string).GetMethod("Con...

Reference generic property in expression

Let's say I have two Tables, Lunch and Dinner. I know that both contain the DateTime property "Time". If I have a generic method GetTime, how could I return db.Lunch.Time when T is Lunch and db.Dinner.Time when T is Dinner? I'm trying to achieve this without testing for T individually using typeof, but rather generically. Pseudocode: ...

Howto emit a delegate or lambda expression

Hello, I want to emit a method that returns a Func<>. Inside this method I have to create a delegate or a lambda expression which exactly serves the return type. Altogether it should look like this: // I have a resolve method that will be called inside my missing method // This is it's signature: object Resolve( params object[] args);...

lambda extension to combine lists

how do i use the second expression to select only those with ID from the first? var list1= from x in objects select x.id; results=results.Where(r=>r.id== ???? ) I want the results to be only those with id from listA tia EDIT:i stand corrected, there was another issue causing problem which i will ask about separately. ...