I have a dynamic select statement thus:
"new(PurchaseOrderID as ID_PK, PContractNo + GoodsSupplier.AssociatedTo.DisplayName as Search_Results)"
As can be seen I wish to concatenate the 'PContractNo' and 'GoodsSupplier.AssociatedTo.DisplayName' fields into one returned field named 'Search_Results'. It is important that these two fields ...
Hi there,
I know the following model code is not correct: as models get loaded only on server boot, time "constants" are loaded at that time only, too.
class Article < ActiveRecord::Base
def expiring?
if (self.enddate - Time.now) <= 1.day
true
else
false
end
end
end
What do I have to correct how, so that...
I am using Linq2SQL and working with a legacy system. The system was built in .Net but without a datalayer so I am transcoding it so that it will have one. I have a linq query that looks like this...
var data = from p in db.tblPeoples
orderby p.strLastName,p.strFirstName
select new
...
I know that I can check whether a list of lists only contains null lists like this
CL-USER> (null (find-if (lambda (item) (not (null item))) my-list))
where my-list is a list of lists.
For example:
CL-USER> (null (find-if (lambda (item) (not (null item))) '(nil (bob) nil)))
NIL
CL-USER> (null (find-if (lambda (item) (not (null item)...
Is that me, or is everyone practicing putting => everywhere it can go?
I guess that I risk myself voted down to oblivion, but it's my opinion that lambdas have their place somewhere, and not everywhere.
So, to the real question - where to use lambda and where NOT to use it?
...
I have a generic class which could use a generic OrderBy argument
the class is as follows
class abc<T> where T : myType
{
public abc(....., orderBy_Argument ){ ... }
void someMethod(arg1, arg2, bool afterSort = false)
{
IEnumerable<myType> res ;
if ( afterSort && orderBy_Argument != null )
res = src.E...
Consider the following code sample:
using System;
using System.Linq.Expressions;
public class Class1<T, Y>
{
public Class1(Expression<Func<T, Y>> mapExpression)
{
GetValue = mapExpression.Compile();
}
public Func<T, Y> GetValue { get; protected set; }
}
public class DataClass
{
public long Data { get; set;...
As short as possible, I have:
class X
{
int p1;
int p2;
int p3;
string p4;
}
class Y
{
int a1;
int a2;
string a3;
string a4;
}
list<X> XLIST;
list<Y> YLIST;
and I want to shorten this:
foreach (X x in XLIST)
{
Y y=new Y();
// arbitrary conversion
y.a1=x.p1;
y.a2=x.p2-x.p1;
...
I am looking for a way to change the following code:
foreach (Contact _contact in contacts)
{
_contact.ID = 0;
_contact.GroupID = 0;
_contact.CompanyID = 0;
}
I would like to change this using LINQ / lambda into something similar to:
contacts.ForEach(c => c.ID = 0; c.GroupID = 0; c.CompanyID = 0);
However that doesn't w...
Hi folks!
There is a common issue to write strongly-typed Html helpers.
The problem is how to retrieve property name/value pair.
Assume we have following Html helper declaration:
public static string DatePickerFor<TModel>(this HtmlHelper<TModel> helper, Expression<Func<TModel, DateTime?>> expression)
There are several solutions I fou...
Basically I want to assign events to some controls that are created. I want to update the labels associated with each trackbar when each trackbar is changed (change label1[i] and label2[i] when trackbar[i] changes). I have waded through google and I found that this probably has be done by using delegates. I had a blast using lambda expre...
I use Framework Entity 4 in my project.
I would like to create a function that will return an Expression
Nothing seem to work. I get this Internal .Net Framework Data Provider error 1025.
Here is my Expression Method
public Expression<Func<SupplierTypeText, bool>> GetLmbLang()
{
return (p => p.LangID == 1);
}
I call...
I often prefer to do this:
a, b = lambda do |data|
[f1(data), f2(data)]
end.call(some_function(some_data))
instead of this:
data = some_function(some_data))
a, b = f1(data), f2(data)
or this:
a, b = f1(some_function(some_data)), f2(some_function(some_data))
Is there any negative consequence from using lambdas for almost ever...
I am trying to create the following Where clause expression dynamically:
context.Cars.
Where(c => EntityFunctions.DiffDays(c.Created, c.Created) == null).
ToList()
This is the code I am using to create the expression:
var parameter = Expression.Parameter(typeof(Car), "c");
var property = Expression.Property(parameter, "Created");
var...
Possible Duplicates:
Good tutorials for lambda
Lamda Explanation and what it is as well as a good example
C# Lambda expression, why should I use this?
Hi can you all explain to me how to use this and give me examples. How do we read it.
Example != is read as "not equals to." So => means what?
...
Hi,
Whenever I add a lambda expression (in the following form) to my wpf project, I get an error. The errors are nothing to do with the expression, but they arrive every time I add one.
here is my latest:
using ( LeisureServiceClient client = ServiceFactory.Instance.GetLeisureService() )
{
client.Execute( ServiceFactory.Instance.C...
Hello!
I need to retrieve all items from two lists that contains a given value.
Example:
var list1 = {
new Dummy(){ Name = "Dummy1", Number = 1 },
new Dummy(){ Name = "Dummy2", Number = 2 },
new Dummy(){ Name = "Dummy3", Number = 3 }
};
var list2 = {
new Dummy(){ Name = "Dummy4", Number = 4 },
new Dummy(){ Name = ...
Hello,
I have the following list :
UserName LanguageSpoken
-------------------------
Bob English
Bob French
Alan Italian
Alan Spanish
Alan German
I'd like to have another list like :
Bob English/French
Alan Italian/Spanish/German
How can I do that using lambda expressions in C#.
Thanks
...
Hi
I just read the Microsoft Surface Tutorial. There is the following C# sample:
private void OnCenterItems(object sender, RoutedEventArgs e)
{
var x = this.Photos.ActualWidth / 2;
var y = this.Photos.ActualHeight / 2;
FindChildren(this.Photos, d => d.GetType() == typeof(ScatterViewItem),
d => ((S...
I have a list of tags that I would like to add to a url string, separated by commas ('%2C'). How can I do this ? I was trying :
>>> tags_list
['tag1', ' tag2']
>>> parse_string = "http://www.google.pl/search?q=%s&restofurl" % (lambda x: "%s," %x for x in tags_list)
but received a generator :
>>> parse_string
'http://<generator...