expressions

What's the difference between anonymous methods (C# 2.0) and lambda expressions (C# 3.0)?

What is the difference between anonymous methods of C# 2.0 and lambda expressions of C# 3.0.? ...

How to get value of Expression<Action<T>> action quickly?

Suppose we have the following code: ExpressionHelper.GetRouteValuesFromExpression<AccountController>(ax => ax.MyAction("a", "b")); (from ASP.NET MVC Futures assembly). Method is reasonably fast - it executes 10k iterations in 150ms. Now, we change code to this: string a = "a"; string b = "b"; ExpressionHelper.GetRouteValuesFromExpre...

Jet(Access) DB and Expression based columns?

I occasionally work on an old project that uses classic asp as a front end and an access database as a backend. I'd like to create a new column in one of the tables that contains logic to calculate its value from the other columns in the row. I know how to do this in a more modern DBMS, but I don't think that access supports it. Keep i...

Evaluating expressions inside C++ strings: "Hi ${user} from ${host}"

I'm looking for a clean C++ way to parse a string containing expressions wrapped in ${} and build a result string from the programmatically evaluated expressions. Example: "Hi ${user} from ${host}" will be evaluated to "Hi foo from bar" if I implement the program to let "user" evaluate to "foo", etc. The current approach I'm thinking ...

What's so great about Func<> delegate?

Hi, Sorry if this is basic but I was trying to pick up on .Net 3.5. Question: Is there anything great about Func<> and it's 5 overloads? From the looks of it, I can still create a similar delgate on my own say, MyFunc<> with the exact 5 overloads and even more. eg: public delegate TResult MyFunc<TResult>() and a combo of various overl...

SSRS Expression Evaluation Issue

I'm having an issue with expressions within reports. I'm coloring the background of a textbox within a table depending on the value within it. The text in the field relates to backups for a SQL Server. The value is either a date or the text "Not Yet Taken". If the date is more than 2 days old, I want the background to be yellow. If ...

Left to right expression evaluation

In C# is it guaranteed that expressions are evaluated left to right? For example: myClass = GetClass(); if (myClass == null || myClass.Property > 0) continue; Are there any languages that do not comply? ...

c++ expected primary expression

I'm working on a very simple game (essentially an ice sliding puzzle), for now the whole things in one file and the only level is completely blank of any form of obstacle. It throws up a few errors. My current annoyance is an expected primary expression error, can anyone tell me how to fix it (it throws up at line 99)? Here's the whole ...

Expression.Or, The parameter 'item' is not in scope.

I am trying to write a static function to Or two expressions, but recieve the following error: The parameter 'item' is not in scope. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in ...

Combining two expressions (Expression<Func<T, bool>>)

I have two expressions of type Expression<Func<T, bool>> and I want to take to OR, AND or NOT of these and get a new expression of the same type Expression<Func<T, bool>> expr1; Expression<Func<T, bool>> expr2; ... //how to do this (the code below will obviously not work) Expression<Func<T, bool>> andExpression = expr AND expr2 ...

LINQ Expression to return Property value?

I'm trying to create a generic function to help me select thousands of records using LINQ to SQL from a local list. SQL Server (2005 at least) limits queries to 2100 parameters and I'd like to select more records than that. Here would be a good example usage: var some_product_numbers = new int[] { 1,2,3 ... 9999 }; Products.SelectByP...

Commerce Server 2007 Expression Syntax Examples

I've been stuck working with Microsoft Commerce Server 2007, in which documentation is almost non-existent (no books etc). Can someone point me to some good examples of eligibility expressions syntax and available variables particularly how it is related to setting up discounts? ...

Sort a List<T> using query expressions - LINQ C#

I have a problem using Linq to order a structure like this : public class Person { public int ID { get; set; } public List<PersonAttribute> Attributes { get; set; } } public class PersonAttribute { public int ID { get; set; } public string Name { get; set; } public string Value { get; set; } } A person might go li...

Classic ASP with Expression Web 2 and Vista

I have previously used Expression Web with XP and MS Server 2003 and in each case I am able to preview .asp pages in the browser. I have now transferred to Vista and get the error "this page may contain dynamic content that requires a Web server...." On the other hand should I wish to preview an HTML page there is no problem. I am awar...

Use Microsoft Scripting Control to evaluate 'If' expressions (via c#)

I have some c# code that uses the Microsoft Scripting Control to evaluate some expressions: using MSScriptControl; // references msscript.ocx ScriptControlClass sc = new ScriptControlClass(); sc.Language = "VBScript"; sc.AllowUI = true; try { Console.WriteLine(sc.Eval(txtEx.Text).ToString()); } catch (Exception ex) { Conso...

reusable condition/expression classes

Hi, I have needed in several occasions some classes to represent and manipulate conditions (typically in a UI so the user builds a query by combining different condition types and then the code can transform that depending on the underlying system to be queried, for example lucene and a db). I searched all over for a reusable set of cla...

Converting an expression to conjunctive normal form with a twist

I've got a library that I have to interface with which acts basically as a data source. When retrieving data, I can pass special "filter expressions" to that library, which later get translated to SQL WHERE part. These expressions are pretty limited. They must be in conjunctive normal form. Like: (A or B or C) and (D or E or F) and ... ...

refactoring boolean equation

Let's say you have a Boolean rule/expression like so (A OR B) AND (D OR E) AND F You want to convert it into as many AND only expressions as possible, like so A AND D AND F A AND E AND F B AND D AND F B AND E AND F You are just reducing the OR's so it becomes (A AND D AND F) OR (A AND E AND F) OR (...) Is there a property in Boo...

Generic Declarative Expression Builder in PHP

Folks, I'm looking to build a piece of PHP5 UI that I'm pretty sure is common to a bunch of applications. Basically, it's an expression builder that allows users to specify expressions combined through logical operators (AND/OR), like this: FieldX > 3 AND FieldY = 5 FieldY = "bob" and FieldZ is not null FieldX > '5/23/2007' OR (Field...

Is there a way to do SSRS Expressions in C#

I am working on a SQl Server Report Services project and the report I am creating requires some custom code. It seems that all expressions must be in VB.NET and I figured if there was an 'easy' way to switch that over to be C#, it would be helpful. EDIT: Well, I decided to move my code to another C# assembly that follows the patterns ...