expression

Reflection Gurus: Why aren't my MethodInfo objects equal?

旧城冷巷雨未停 提交于 2019-12-23 17:18:33
问题 Basically, some internal check that happens in the static System.Linq.Expressions.Expression.Bind() method says "Method is not a property accessor" on my property that is clearly a property. Using Reflector, I've minimized the amount of code causing the problem, and I can't for the life of me figure out why this would happen. My only guess is that it has something to do with the fact that the property isn't on the class itself, but I would think this should still work: I've tried to make a

Is there a way to capture a lambda expression so that it's not compile-time forced to take on an identity as either an Expression or Delegate type?

你离开我真会死。 提交于 2019-12-23 17:11:26
问题 Suppose I have a complex lambda expression as follows: x => x.A.HasValue || (x.B.HasValue && x.C == q) || (!x.C.HasValue && !x.A.HasValue) || //...expression goes on I want to use this as an Expression<Func<T,bool> in (e.g. Linq-To-Entities) Queryable.Where method. I also want to use it in the Enumerable.Where method, but the Where method only accepts a Func<T,bool> , not an Expression<Func<T,bool> . The lambda syntax itself can be used to generate either an Expression<Func<T,bool>> or a Func

Boost spirit takes for ever to parse expressions

怎甘沉沦 提交于 2019-12-23 16:24:47
问题 i am new here working with boost spirit Reading alot of very good articels for boost Spirit i decide to make an own Parser and run into the Problem that parsing an Expression like this 1+(2+(3+(4+(5+(6+(7+(8))))))) takes forever on runtime.. making it more simple 1+(2+(3)) works fine. I Looks like the backtracking of the Parser is active. Please give me a hint how to modify the grammer or behaviour to make this run in time. Here is a bit code from the grammer. I use the "iter_pos" for

FTP Connection string using expression in SSIS

天涯浪子 提交于 2019-12-23 15:33:47
问题 In my SSIS 2005 package, I need to give the FTP Connectionstring via an expression as I need to keep it configurable for the user from the dtsConfig file. At the moment I tried giving the following expression: Connectionstring = @[User::FTPServer] + "." + @[User::FTPUser] + "." + @[User::FTPPass] For this unique syntax, I took pointers from the discussion at http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/3713e9a5-343a-4c5b-ac5d-1508cd5ab8be My FTPServer variable

How to get rid of unnecessary parentheses in mathematical expression

…衆ロ難τιáo~ 提交于 2019-12-23 15:06:38
问题 Hi I was wondering if there is any known way to get rid of unnecessary parentheses in mathematical formula. The reason I am asking this question is that I have to minimize such formula length if((-if(([V].[6432])=0;0;(([V].[6432])-([V].[6445]))*(((([V].[6443]))/1000*([V].[6448]) +(([V].[6443]))*([V].[6449])+([V].[6450]))*(1-([V].[6446])))))=0;([V].[6428])* ((((([V].[6443]))/1000*([V].[6445])*([V].[6448])+(([V].[6443]))*([V].[6445])* ([V].[6449])+([V].[6445])*([V].[6450])))*(1-([V].[6446])));

DataTable expression Cannot interpret token '!'

最后都变了- 提交于 2019-12-23 12:19:23
问题 I have the following code: //myDataTable has the following collumns: UserName, Birthday and email. string name = "eric!"; string expression = "UserName = " + name; DataRow[] result = myDataTable.Select(expression); I want to select all rows with the name "eric!". The "!" gives me the following error: Cannot interpret token "!". How can I select all rows with such tokens? (I really need the "!" in the expression since I extract the userNames from a .sql file) 回答1: You should use your name

How might I clean up this lambda?

守給你的承諾、 提交于 2019-12-23 10:25:23
问题 I have an expression that I use a few times in several LINQ queries so I separated it out into it's own method that returns the expression. The lambda portion of the function is kind of messy looking. Anyone want to take a crack at refactoring it and making it more readable and/or smaller? private Expression<Func<Message, bool>> UserSelector(string username, bool sent) { return x => ((sent ? x.FromUser : x.ToUser).Username.ToLower() == username.ToLower()) && (sent ? !x.SenderDeleted : !x

Using a regular expression to validate whether input has any non digits in it

安稳与你 提交于 2019-12-23 09:28:43
问题 function validInteger(theNumber){ var anyNonDigits = new RegExp('\D','g'); if(parseInt(theNumber)&&!anyNonDigits.test(theNumber)){ return true; }else{ return false; } } Above is a function I've written to validate some input. I want all positive integers. The problem I'm facing is with the RegExp object. This seems like it should be super simple, but for some reason it's not working. For example if I pass 'f5' I get true, but if I pass '5f' I get false. I'm also having problems when passing

call return inside GCC compound statement expressions

空扰寡人 提交于 2019-12-23 09:26:24
问题 Can I safely use return inside GCC compound statement expressions ? For example I define macro #define CHECK_FUNC_RESULT(func) \ ({ \ int result = func(); \ if (!result) return; \ result; \ }) and use it somewhere in code in such way: int function1() { if (some_condition) return 0; ... return 1; } void function2() { if(CHECK_FUNC_RESULT(function1)) { ... to do something } } Can I expect returning from function2 (on some_condition == true) without any undefined behavior ? 回答1: It should work,

How do I use IF/ELSE or CASE In DataColumn.Expression?

青春壹個敷衍的年華 提交于 2019-12-23 09:14:47
问题 I have a table with 1 column: 'Status' I want to add in another column named 'Action', its value will be as follow: if Status = 'Yes' Then Action = 'Go', otherwise, Action = 'Stop'. I used this following code to add in column 'Action' but it didn't work: myDataTable.Columns.Add("Action", typeof(string), "IF [Status] = 'Yes' THEN 'Go' ELSE 'Stop' END"); 回答1: The expression you are looking for is: IIF( [Status] = 'Yes', 'Go', 'Stop' ) DataTables do not support standard SQL CASE statements, nor