I am using Entity Framework in my C# based code. I am running into an unexpected weirdness and am looking for suggestions.
Case 1, 2, 3, 4...
Projects:
RivWorks.dll
RivWorks.Service.dll
RivWorks.Alpha.dll
Samples (all of these work):
RivWorks.Alpha.dll:
public static bool EndNegotitation(long ProductID)
{
var product = (from a ...
I'm a newbie when it comes to expression trees, so I'm not sure how to ask this question or what terminology to use. Here's an overly-simplifed version of what I'm trying to do:
Bar bar = new Bar();
Zap(() => bar.Foo);
public static void Zap<T>(Expression<Func<T>> source)
{
// HELP HERE:
// I want to get the bar instance and call...
According to Charlie Poole's NUnit blog, it is possible to use Lambda expressions as constraints in NUnit 2.5. I just can't seem to be able to get it to work? I am using NUnit 2.5.3.9345.
Using the example lambda from the blog post:
[TestFixture]
public class Class1
{
[Test]
public void someTest()
{
int[] array = {1...
Hello,
I have a strange behavior. The code below worked from a long time but nowI don't know why I didn't change anything, I have an exception. I get employee from my database via Nhibernate, the _model.List have the employee list. I have an exception on the line juste before the return (where I build the array). I format the data to us...
i am new to c++0x, so please excuse me if my question is silly :).
i am writing the following recursive lambda function, it doesn't compile.
sum.cpp
#include <iostream>
#include <functional>
auto term = [](int a)->int {
return a*a;
};
auto next = [](int a)->int {
return ++a;
};
auto sum = [term,next,&sum](int a, int b)mutable -...
I have some extension methods which could be used like this:
MyType myObject;
string displayName = myObject.GetDisplayName(x => x.Property);
The problem here is that it needs an instance, even if the extension method only needs the type MyType. So if there is no instance, it needs to be called like this:
string displayName = BlahBla...
Hi!
Given the lambda expression below where Province type contains a public property "byte CountryId" and Country type which contains a public property "byte Id".
Expression<Func<Province, bool>> exp = p => p.CountryId == country.Id;
The Expression is later used by NHibernate Linq provider and threw an exception. When I inspected th...
I want to take a class, loop through it's properties, get the property value, and call a method passing that property value in. I think I can get the property values, but what does the lambda expression's body look like? What body is used to call a method on each property?
This is what I have so far...
Action<T> CreateExpression<T>( T...
Most programming languages are utilizing lambdas/closures.
Which language agnostic source is recommended as the best to learn Lambda basics?
Lambdas/Closures in different languages:
Perl Lambdas
Python Lambdas
.Net LINQ
Java Closures
Scheme
Lisp
Php Closure and Lambdas
Javascript Closures
C++
ML
Wikipedia: Closures (computer science)...
Hi there,
I'm stuck with the problem below and wondering is someone out there will be able to help. I have added comments to the code to make it self-explanatory but let me know if you need more info or if the problem is unclear.
Thanks a lot in advance!
Edit: I've been asked to summarize the problem in text, so here it goes: under th...
Note: I have condensed this article into my person wiki: http://wiki.chacha102.com/Lambda - Enjoy
I am having some troubles with Lambda style functions in PHP.
First, This Works:
$foo = function(){ echo "bar"; };
$foo();
Second, This Works:
class Bar{
public function foo(){
echo "Bar";
}
Third, This works:
$fo...
I got bored during the holiday season this year and randomly decided to write a simple list comprehension/filtering library for Java (I know there are some great ones out there, I just wanted to write it my self for the hell of it).
For this list:
LinkedList<Person> list = new LinkedList<Person>();
list.add(new Person("Jac...
So I find myself writing this code all the time:
[TestMethod]
[Description("Asserts that an ArgumentNullException is thrown if ResetPassword(null) is called")]
public void ResetPassword_Throws_ArgumentNullException_With_Null_Parameter( )
{
try
{
new MembershipServiceProvider( ).ResetPassword( null );
}
catch ( A...
Functionally, is there any difference (apart from syntax onbviously) between lambda expressions in C# and VB.Net?
EDIT: following up on CraigTP's answer: any references to the situation in .Net 4?
EDIT: I'm asking because I'm used to C#, but for a next project the customer asks VB.Net. We're not a priori against that. We realize that m...
anybody knows how to make a method (I will put it in a extensions class) that will do the same as the mvc's RedirectToAction only using expressions (no magic strings).
So that instead of writing something like this:
RedirectToAction("Detail",
new RouteValueDictionary { {"messageId", messageId}});
I would do like this:
this.Red...
In C# I would simply do this:
myIEnumerable.Where(i=>i.ReturnsABool()).any();
How would I do that in VB.net?
I'm stuck on how to formulate the lambda..
...
I'm looking for something similar to SQL for Smarties by Joe Celko. More specifically I'm interested in .Net 3.5 or 4.0.
...
I had a part of code that takes in lambda expressions at runtime, which I can then compile and invoke.
Something thing;
Expression<Action<Something>> expression = (c => c.DoWork());
Delegate del = expression.Compile();
del.DynamicInvoke(thing);
In order to save execution time, I stored those compiled delegates in a cache, a Dictionar...
Ok, here's a tricky one. Hopefully there is an expression guru here who can spot what I am doing wrong here, cause I am just not getting it.
I am building up expressions that I use to filter queries. To ease that process I have a couple of Expression<Func<T, bool>> extension methods that makes my code cleaner and so far they have been w...
I have a list of objects. Each object contains a property called 'DisplayName'.
I want to create another list of string objects, where each string represents the first letter or character (could be a number) in the DisplayName property for all objects in the initial list, and I want the list to be distinct.
So, for example, if my list...