Let's assume that I have two classes:
class person
{
int ID
string name
Address address
}
class address
{
int ID
string street
string country
}
These classes are more or less given, they are mapped via nHibernate to be honest :)
In a grid (datatables.net as base) I would like to have a type-independent sorting...
Hello all
I have an XML file that is loaded into an XElement. I want to count the number of PollEvent children that both exist and that satisfy some conditions. I have got the code working to count the number of PollEvents in total but when I come to filter this list I do not seem to be able to call .Where, I believe this to is due to...
I checked out the latest Ruby version, to play a bit with the latest changes. The first thing I tried to do was call a Ruby lambda/block/proc just like you'd do with a Python callable.
a = lambda {|x| puts x}
a.call(4) # works, and prints 4
a[4] # works and prints 4
a.(4) # same
a(4) # undefined method 'a' for main:Object
Why isn't th...
I just cannot get this to work, would appreciate if someone can help.
So I get back an XML result from a database which looks like:
<matches>
<issuer client_name="MTR" score="6" match_list="MTR CORPORATION LIMITED"/>
<issuer client_name="PEOPLE''S REPUBLIC OF CHINA" score="4"
match_list="DEMOCRATIC PEOPLE'S REPUBLIC OF KO...
This is the code I need to alter:
var xParam = Expression.Parameter(typeof(E), typeof(E).Name);
MemberExpression leftExpr = MemberExpression.Property(xParam, this._KeyProperty);
Expression rightExpr = Expression.Constant(id);
BinaryExpression binaryExpr = MemberExpression.Equal(leftExpr, rightExpr);
//Create Lambda Expression for the se...
I have a list of objects that I am trying to bind to a listview. I am sorting by two properties. The problem exists whereby some records may not have one of the properties. This is causing an error. I would like it to still bind the records that have the property.
IEnumerable<ERec> list = retailerList.Cast<ERec>();
lvwRetailStores.DataS...
I have been using LINQ with compiled queries, basically passing into the compiled query using Func but the problem is that it has a maximum of four parameters.
Is it good practice to extend this?
Is there any way to extend this or should I create my own delegate?
Sometimes I need to pass six params and others five and others four or l...
I am currently looking at lambda expression and the word closure keeps coming. Can someone explain it to me in real simple language.
...
Hi there,
Can anyone help?
I have a linq query which is embedded inside a extension method, it was working as v.RentalStatus was a String. I am now using a Group on my original query (the query is quite complex so i won't put it here).
The importante thing is that v.RentalStatus = IEnumerable hence it can contain things like
A (meani...
I've got a String array that I'm wanting to add to a string builder by way of LINQ.
What I'm basically trying to say is "For each item in this array, append a line to this StringBuilder".
I can do this quite easily using a foreach loop however the following code doesn't seem to do anything. What am I missing?
stringArray.Select(x => s...
We have a class called Task:
public partial class Task : EntityObject
{
public EntityCollection<TaskUser> TaskUsers { get {...} set{...} }
}
It has navigation property called TaskUsers, which contains users attached to this taks:
public partial class TaskUser : EntityObject
{
public User User { get {...} set { } }
}
Every...
I see lambda expressions have become a very useful tool at some points in the language. I've been using them a lot and most of the time they fit really nice and make the code shorter and perhaps clearer.
Now.. I've seen some , I would say excessive use of them. Some people like them so much that try to use them everywhere they can.. Som...
Given a class structure like this:
public class GrandParent
{
public Parent Parent { get; set;}
}
public class Parent
{
public Child Child { get; set;}
}
public class Child
{
public string Name { get; set;}
}
and the following method signature:
Expression<Func<TOuter, TInner>> Combine (Expression<Func<TOuter, TMiddle>>> ...
I am looking at the MvcContrib Grid component and I'm fascinated, yet at the same time repulsed, by a syntactic trick used in the Grid syntax:
.Attributes(style => "width:100%")
The syntax above sets the style attribute of the generated HTML to width:100%. Now if you pay attention, 'style' is nowhere specified, is deduced from the na...
I'm clearly missing something here... I have a generic list of objects and I'm trying to use a lambda expression to remove items. When I use the code posted below I get the following exception.
System.InvalidOperationException: Sequence contains no matching element
public class MyObject {
public Guid ID1 {get;set;}
public i...
Hi everybody :)
I often find myself using lambdas as some sort of "local functions" to make my life easier with repetetive operations like those:
Func<string, string> GetText = (resource) => this.resourceManager.GetString(resource);
Func<float, object, string> FormatF1 = (f, o) => String.Format("{0:F1} {1}", f, o);
Func<float, object, ...
I am learning lambda expression and delegates.While i try to execute the following ,I am getting error at the line which is marked bold line. (Error : Operator '+=' cannot be applied to operands of type 'Test.MessageDelegate' and 'lambda expression').Help me to handle lambda expression.
namespace Test
{
public delegate void Message...
Are there any "simple" explanations of what procs and lamdbas are in Ruby?
...
I'd like to declare an "empty" lambda expression that does, well, nothing.
Is there a way to do something like this without needing the DoNothing() method?
public MyViewModel()
{
SomeMenuCommand = new RelayCommand(
x => DoNothing(),
x => CanSomeMenuCommandExecute());
}
private voi...
I've done a brief search of this site, and googled this, but can't seem to find a good example. I'm still trying to get my head around the whole "Lambda Expressions" thing.
Can anyone here give me an example ordering by multiple columns using VB.Net and Linq-to-SQL using a lambda expression?
Here is my existing code, which returns an o...