expression

Parsing dates from string - regex

时间秒杀一切 提交于 2019-12-25 02:40:28
问题 I'm terible with regex and I can't seem to wrap my head around this simple task. I need to parse out the two dates in a string which always has one of two formats: "Inquiry at your property for December 29, 2013 - January 03, 2014" OR "Inquiry at your property for 29 December , 2013 - 03 January, 2014" the 2 different date formats are throwing me off. Any insights would be appreciated! 回答1: /(\d+ \w+, \d+|\w+ \d+, \d+)/ for example. Try it out on Rubular. For sure, it would pickup more stuff,

JPQL like expression requires int value

孤街浪徒 提交于 2019-12-25 02:21:24
问题 I'd like to search a requested value in my database using the entity manager createquery function. Whenever I executed my method, I got the following error message: llegalArgumentException: You have attempted to set a value of type class java.lang.String for parameter searchvalue with expected type of int from query string It says that a int value is required, but I think that every like expression requires a string value? Entity: public class Contract implements Serializable { private static

Need help creating Linq.Expression to Enumerable.GroupBy

孤街浪徒 提交于 2019-12-25 01:46:39
问题 I am attempting to generate an Expression tree that ultimately calls a series of GroupBy methods on the Enumerable type. In simplified form I am attempting something like this: IEnumerable<Data> list = new List<Data>{new Data{Name = "A", Age=10}, new Data{Name = "A", Age=12}, new Data{Name = "B", Age=20}, new Data{Name="C", Age=15}}; Expression data = Expression.Parameter(typeof(IEnumerable<Data>), "data"); Expression arg = Expression.Parameter(typeof(Data), "arg"); Expression nameProperty =

problem in boolean expression with if statement

戏子无情 提交于 2019-12-25 01:27:20
问题 I need some confirmation. I always get correct o/p but someone told me following expression will not work Thanks in advance. #define a 11 #define b 12 #define c 13 // I want if array[i] has values of any of these then do something if( array[i] == (a) ||(b) ||( c)) // some function else printf("no match"); 回答1: Replace your code with this: if( array[i] == a || array[i] == b || array[i] == c) Each part of the boolean condition must be a complete expression. While what you wrote is valid C code,

How to evaluate a lambda expression to determine object type

白昼怎懂夜的黑 提交于 2019-12-25 00:33:28
问题 public class Tomato {} public class Potato {} public class UIPotatoBinding(Expression<Func<object>> expression) { // What to put here to make sure lambda results in Potato(s) } public class UITomatoBinding(Expression<Func<object>> expression) { // What code do I need to put here to determine if the lambda expression being passed in // results in Tomato, List<Tomato>, IEnumerable<Tomato>, ObservableCollection<Tomato> // TomatoCollection, or some other Tomato related Linq construct. } This

Lambda expression C# failed to convert to the object type and fail with ref

折月煮酒 提交于 2019-12-24 21:07:31
问题 Have such function: private static void EncodeString(ref string str) { using (RLE inst_rle = new RLE()) { string str_encoded = inst_rle.Encode(ref str); Console.WriteLine( "\r\nBase string ({0} chars): {1}\r\nAfter RLE-encoding ({2} chars): {3}\r\nCompression percentage: %{4}", str.Length, str, str_encoded.Length, str_encoded, () => { (100 * (str.Length - str.encoded.Length) / str.Length); } ); } } As I remember it's a style of lambdas in C#: () => { < action > ; } But getting such errors:

Write a translatable method for LINQ TO Entities

╄→尐↘猪︶ㄣ 提交于 2019-12-24 18:43:33
问题 Using Entity Framework (LINQ to Entities) The following is working just fine. The expressions got translated to SQL var foos = ctx.Foos.Select(f => new { P1 = ctx.Bars.FirstOrDefault(b => b.SomeProp == "Const1" && f.X1 == b.Y), P2 = ctx.Bars.FirstOrDefault(b => b.SomeProp == "Const2" && f.X2 == b.Y), P3 = ctx.Bars.FirstOrDefault(b => b.SomeProp == "Const3" && f.X3 == b.Y), } The repetitive expression b.SomeProp == "..." && f.X* == b.Y is actually a simplified version of the real expression,

Write a translatable method for LINQ TO Entities

和自甴很熟 提交于 2019-12-24 18:43:04
问题 Using Entity Framework (LINQ to Entities) The following is working just fine. The expressions got translated to SQL var foos = ctx.Foos.Select(f => new { P1 = ctx.Bars.FirstOrDefault(b => b.SomeProp == "Const1" && f.X1 == b.Y), P2 = ctx.Bars.FirstOrDefault(b => b.SomeProp == "Const2" && f.X2 == b.Y), P3 = ctx.Bars.FirstOrDefault(b => b.SomeProp == "Const3" && f.X3 == b.Y), } The repetitive expression b.SomeProp == "..." && f.X* == b.Y is actually a simplified version of the real expression,

regular expression match Thursday, Thurs, Thur,Thu

邮差的信 提交于 2019-12-24 18:41:26
问题 I want a regexp to match partial weekday names. For example, I want to match "Thursday", "thurs", "thur" or "Thu". I tried "thu(rsday)?", but that only matched "thu" and "thursday". The complete regular expression to match abbreviated weekdays would be excessively long. I tried this regex string: Mon(day)?|Tue(sday)?|Wed(nesday)?|Thu(rsday)?|Fri(day)?|Sat(urday)?|Sun(day)? The strings I have look like this: 3-Dec Mon 1:00pm Premiere USPHL Sk3-Red 4-Dec Tue 8:10pm U16 USPHL Sk3-Red 6-Dec Thur

SSRS Split expression #Error

你说的曾经没有我的故事 提交于 2019-12-24 18:28:19
问题 Trying to get this expression working: IIF(Fields!Text.Value like "*som:*",Split(Fields!Text.Value, ": ").GetValue(0)&":" & vbcrlf & Split(Fields!Text.Value, ": ").GetValue(1), Fields!Text.Value) And for the fields which contain "som:" it works as I want but not for the "else fields" which show #Error. I've also tried Fields!Text.Value.ToString().Contain("som:") but got the same result. The Warning goes: The Value expression for the textrun ‘XXXXXX.Paragraphs[0].TextRuns[0]’ contains an error