expression

“Or” Together Expression<Func<EntityFramework Entity, bool>> in .NET 4, Silverlight RIA domain service

余生颓废 提交于 2019-12-13 02:37:38
问题 I have a small custom object defined as: public class TimeSeriesDefinition { public int classID; public DateTime startTime; public DateTime endTime; } I'm passing a List classIDs, a List startTimes, and a List endTimes into an RIA Domain Service function. As a matter of organization, I was grouping these values into a List of TimeSeriesDefinitions and then trying to use a foreach loop to create an expression that would select with AND operators between the values in a class and OR operators

How to escape single quote within string variable in NCalc.Expression - Backslash didn't work

白昼怎懂夜的黑 提交于 2019-12-13 01:59:17
问题 I am using NCalc.Expression to evaluate a condition which involves comparison with string values that contain single quote within them. In NCalc, string is represented using single quote instead of double quotes. Ex: [variable1]=='Sample's Data' In order to escape the single quote, I tried appending a backlash like this - [variable1]=='Sample\'s Data' But when this is assigned to a string variable, it removes the backslash as - [variable1]=='Sample's Data' and after assigning this to the

How to validate a boolean in Struts 2 Validation Framework

帅比萌擦擦* 提交于 2019-12-13 01:19:32
问题 Simple: I have to be sure the privacy checkbox on my form is checked. I tryed to use the expression validator (and the fieldexpression validator) but it does'n work. Can anobody help me? 回答1: Can you provide more information? How were you using the expression validator, and why didn't it work? Seems like that approach should work fine. A few things to consider: do you have both a "getter" and a "setter" method for your boolean? Do you have both the "validation" and the "workflow" interceptors

Convert Expression to Expression<Func<T, bool>>

拜拜、爱过 提交于 2019-12-13 01:12:58
问题 Is that possible to convert Expression to Expression<Func<T, bool>> if instance of Expression was created on T ? At the end I have list List<Expression> and need to produce on Expression<Func<T, bool>> where each expression of List<Expression> is agregated with AND . 回答1: Yes; just call Expression.Lambda<Func<T, bool>>(..., parameter) , where ... is an expression composed of the expressions you want to combine. You'd probably want list.Aggregate(Expressions.AndAlso) . If your expressions don

How to test expressions equality [duplicate]

自作多情 提交于 2019-12-13 00:36:02
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Most efficient way to test equality of lambda expressions How to check if two Expression<Func<T, bool>> are the same How to test that two expressions are the same like this sample string firstname = "Ahmed"; Expression<Func<string, bool>> exp1 = (s) => s.Contains(firstname); Expression<Func<string, bool>> exp2 = (s) => s.Contains(firstname); Console.WriteLine(exp1 == exp2);//print false as two references are no

Getting type of items of a List at run-time in c#

只谈情不闲聊 提交于 2019-12-13 00:11:38
问题 I need an expression that gets type of every item of a collection. I have a collection like this: var collection = new List<object>{1,2.2,"string",'c'}; It's possible to get type of every item of collection like this: var myVariable= collection.Select(item => item.GetType()) But I need creation of this expression at run-time. I have to create something like myVariable dynamically, but how?! Debugger shows me value of internal expression of myVariable like this: {System.Linq.Enumerable

Is a single constant value considered an expression?

非 Y 不嫁゛ 提交于 2019-12-12 20:17:14
问题 After reading this answer on a CSS question, I wonder: In Computer Science, is a single, constant value considered an expression? In other words, is 7px an expression? What about just 7 ? Quoting Wikipedia, emphasis mine: An expression in a programming language is a combination of one or more explicit values , constants, variables, operators, and functions that the programming language interprets [...] and computes to produce [...] another value . This process, as for mathematical expressions

C character values arithmetic

╄→гoц情女王★ 提交于 2019-12-12 20:12:48
问题 I have been reading from the book "The C Programming Language" learning C, and I stumbled upon the arithmetic s[i] - '0' which they said that it gives the numeric value of the character stored in s[i]. I didn't quite understand it, how could it give the value by subtraction? Note This is used in the atoi function, which converts a string of digits into its numeric equivalent. Thanks 回答1: Basically, what you need to understand is that on a modern computer, all information is stored digitally

Python - extracting split list correctly

主宰稳场 提交于 2019-12-12 19:20:00
问题 As a follow up to this question, I have an expression such as this: ['(', '44', '+(', '3', '+', 'll', '))'] which was created by using re.findall('\w+|\W+',item) method, however within this list of strings, there are two errors. One is the '+(' and the other is the '))'. Is there a pythonic way that I could split just the operators such that the list would be something like ['(', '44', '+','(', '3', '+', 'll', ')',')'] . (keep the digits/letters together, separate the symbols) Thanks 回答1:

RegEx to place tags around matched word

放肆的年华 提交于 2019-12-12 19:03:20
问题 I want to put bold tags around words that match in a string. However, I also need to be able to find the matched words in a url. If possible I would like to have one RegEx for everything. Here's what I have tried so far: I have tried new RegExp("(^|\\s)(" + match.join('|') + ")(\\s|$)","ig") and new RegExp('(\\b)(' + match2.join('|') + ')(\\b)','ig') //keyword var keyword = "Donec sed odio bacon dui."; var match = ["donec", "bacon", "dui"]; //why does it ignore dui??? var reg1 = new RegExp("(