Well lets separate this into LINQ to Objects and LINQ to Entities In LINQ to Object the above fails because the compiler doesn't know what the Property name is, if you change it to this: var mySelection = from a in myContainer where a=somecondition select new { a. Prop1, prop2 = myMethod(a. Prop2) } It will work in LINQ to Objects However the Entity Framework won't be able to translate the method call (unless it is a function known to the EF like a Model Defined Function, EdmMethods or SqlMethods) so you'll have to rewrite that query like this: var mySelection = from a in myContainer where a=somecondition select new { a.
Prop1, a. Prop2 }; var myResults = from a in mySelection.AsEnumerable() select new {a. Prop1, prop2 = myMethod(a.
Prop2)} This pulls what you need out the database, and then using the AsEnumerable() call turns the call to myMethod into something processed by LINQ to Objects rather than LINQ to Entities Hope this helps Alex.
Well lets separate this into LINQ to Objects and LINQ to Entities In LINQ to Object the above fails because the compiler doesn't know what the Property name is, if you change it to this: var mySelection = from a in myContainer where a=somecondition select new { a. Prop1, prop2 = myMethod(a. Prop2) }; It will work in LINQ to Objects However the Entity Framework won't be able to translate the method call (unless it is a function known to the EF like a Model Defined Function, EdmMethods or SqlMethods) so you'll have to rewrite that query like this: var mySelection = from a in myContainer where a=somecondition select new { a.
Prop1, a. Prop2 }; var myResults = from a in mySelection.AsEnumerable() select new {a. Prop1, prop2 = myMethod(a.
Prop2)}; This pulls what you need out the database, and then using the AsEnumerable() call turns the call to myMethod into something processed by LINQ to Objects rather than LINQ to Entities Hope this helps Alex.
Tried this, doesn't work: "Anonymous type members must be declared with a member assignment, simple name or member access. " – Dave Swersky Nov 10 '09 at 16:33 Well it 'works on my machine'! – Alex James Nov 10 '09 at 19:24 OK, got it.Works.
– Dave Swersky Nov 11 '09 at 16:56.
I don't think there is a way to call out to a method from an anonymous initializer. Even if there were, it probably wouldn't perform very well. If you need to create a result set that requires additional processing, I would create a concrete class.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.