Hello there,
I have just found some misterious behaviour while working with System.Linq.Expressions.Expression and System.Reflection.MethodInfo.
The code is as follows:
static void Main(string[] args)
{
Expression<Func<double, double, double>> example = (x, y) => Math.Sin(x);
//Prints out "x, y":
Cons...
Hi,
I've been tearing my hair out with this one. I've got an array of search terms and I'm trying to do a LINQ to SQL query to search field values against each item in the array.
I got this far..
var searchResults =
from x in SDC.Staff_Persons
where staffTermArray.Any(pinq => x.Forename.Contains(pinq))
|| staffTermArr...
Hi Guys,
I want a Inline Lambda Expr for the line highlighted:
foreach (ReminderData rd in lstReminders)
{
divReminders.InnerHtml += "<A onclick='javascript:openRadWindow('" + rwmManager.ClientID +
"', 'rwReminder', '/clientwebnew/CRApps/Contacts/TicketReminder.aspx?formOnly=yes&Menu=" +
this.MenuId.ToString() +
"&ticketid=" + this...
let there be :
Expression<Func<Message, bool>> exp1 = x => x.mesID == 1;
Expression<Func<MessageDTO, bool>> exp2 = x => x.mesID == 1;
now i need to pass exp1 to _db.Messages.where(exp1); problem is i only have exp2, i need to convert the type to Message , All properties are the same !
now i do this :
var par = Expression.Parameter...
Supposed i have an array int[] arr = {1,2,3,4}
I want to convert it into a string.
The result i want it to be like this string a = "1,2,3,4";
so can i have something "string a = arr...." to do it, instead of writing a for loop??
Thanks
...
I would like to create an expression tree for a query expression that looks something like this:
employee => employee.Salary.StartsWith("28")
So that the sql could appear as:
where (employee.salary like '28%')
The problem is that the property Salary of the employee object is a decimal and StartsWith is not a property of a decimal...
Using visual studio 2008 with the tr1 service pack and Intel C++ Compiler 11.1.071 [IA-32], this is related to my other question
I'm attempting to write a functional map for c++ which would work somewhat like the ruby version
strings = [2,4].map { |e| e.to_s }
So i've defined the following function in the VlcFunctional namespace
te...
Hi!
I'm using entity framework to connect the database.
I've a table(Let's call it "File") that haves several fields:
ID, Version, XYZ
Primarky key is based on ID AND Version.
so I can have several line with the same ID but different version(and inversly).
The question is:
How can I, with a LAMBDA expression, ask my Entity Framewor...
Basically, I want to know if something like the below is possible? If this isn't possible is there any way to fake it?
#include <iostream>
using namespace std;
template<typename Functor>
void foo(Functor func)
{
auto test = [](Functor f){ int i = 5; f(); };
test(func);
}
int main()
{
foo([](){ cout << i << endl;});
}
...
I wrote the following code on VC10. Calling f1 is okay, but on calling f2 the compiler showed an error. The difference between the two functions is only "template ", but the template type is actually not used. Why does the error occur?
#include <functional>
void f1( std::tr1::function<void()> f)
{
}
template <typename >
void f2( std::...
So, I'm trying to figure out Expression trees. I'm trying to add in a dynamic equals to a Queryable where T is one of several different tables. I'm first checking the table contains the field I want to filter on.
ParameterExpression param = Expression.Parameter(typeof(TSource), "x");
Expression conversionExpression = Expression.Convert...
I have a lambda selector, lets say Func<T, TResult>. Is it possible to convert it into a predictor (Func<T, bool>) using a TResult object as reference?
For example, convert
x => x.Name
into
x => x.Name == customerName
...
I'm seeing a pattern throughout my code where the lambda expression is showing as not covered in code coverage, the debugger DOES step through the code and there are no conditional blocks.
public CollectionModel()
{
List<Language> languages = LanguageService.GetLanguages();
this.LanguageListItems =
languages.Select(
...
How do I insertsect two lists of KeyValuePairs based on their keys? I have tried:
List<KeyValuePair<string, string>> listA = new List<KeyValuePair<string, string>>();
List<KeyValuePair<string, string>> listB = new List<KeyValuePair<string, string>>();
...
var result = listA.Intersect(listB);
Which expectedly doesn't work. Do I need to...
Hi, I started with the IQueryable extension methods from this example on CodePlex.
What i believe i need is an IQueryable extension method to "Where", where the method signature looks like:
public static IQueryable<T> Where<T>(this IQueryable<T> source, string columnName, string keyword)
and effectively does this (assuming T.columnNa...
Hi folks,
I'm trying to do some eager loading on an EF Entity.
so, if the entity is called Orders .. then I guess i would do the following...
_someContext.Orders.Include("Whatever") ....
But the problem is, I have a method like the following ...
public IQueryable<Order> Find(Expression<Func<Order, bool>> predicate)
{
return Curr...
I'm having issues with a rather complex Linq query and I need some advice. This involves VB syntax so I need specific answers for that platform, as I have a lot of trouble translating the C# syntax to VB at times.
I have to join two main tables, and I need to filter the results by elements in an ASP.NET web form. These filters are c...
Hi,
Is it possible to write a lambda expression that will iterate through array of objects and replace all occurences of 'X', 'Y', ' ' and 'Z' in one of the properties?
E.g.
return query.Select(x => { x.SomePropertyName= x.SomePropertyName.Trim().Replace(' ', "_"); return x; }).ToList();
For some reason, a query above doesn't repla...
I haven't really been able to get a firm grasp on creating and using lambda expressions. I know how to use them in linq statements, but I really don't understand what's going on behind the scenes. I also havent been able to find a complete tutorial on when to use them, how to define them, etc.
Second part...
They say that Javascript ...
I'm a Ruby newbie (started 4 days ago and hey it rhymes!) and decided to code a simple little tool for fun/learning. The following code was the result. It works fine, but I would really appreciate critique from some more experienced Ruby developers. I'm looking for comments on style, verbosity, and any misc. tips/tricks.
By the way, I'm...