当Im使用LINQ来制造有活力的 s时,我不希望它预先确定和计算成百分数,如果在我身上使用百分数的Im不希望逃脱。 它避开了我所增加的百分比标志,将~用作逃生顺序之前的预留标记。
例如:
string str = %test%.doc%
.Contains(str) // converts this into LIKE %~%test~%.doc~%%
预期转化:%
当Im使用LINQ来制造有活力的 s时,我不希望它预先确定和计算成百分数,如果在我身上使用百分数的Im不希望逃脱。 它避开了我所增加的百分比标志,将~用作逃生顺序之前的预留标记。
例如:
string str = %test%.doc%
.Contains(str) // converts this into LIKE %~%test~%.doc~%%
预期转化:%
见https://stackoverflow.com/questions/2165453/using-linq-contains-versus-sqlmethods- similar>Using LINQ Contains vs. SqlMethods.Like , 一般而言,
简单例子: http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/10/16/linq-to-sql- similar-operator.aspx”rel=“nofollow noretinger” http://blogs.microsoft.co.il/blogs/blogs/bursteg/archive/2007/10/16/linq-to-sql-formerator.aspxvar res = from row in dc.Table
where SqlMethods.Like(row.Column, "%A%A%")
select row;
集装箱可能会被转化为在Kall使用LIKE
的操作器。 该操作员将<>%作为野心。 <代码>Contains ("abc”)map to LIKE %abc%
。
我利用以下延长时间来避免这种情况(尽管在我的具体情况下,我仍然使用野心,但你可以自行修改。
public static bool Like(this string value, string term)
{
Regex regex = new Regex(string.Format("^{0}$", term.Replace("*", ".*")), RegexOptions.IgnoreCase);
return regex.IsMatch(value ?? string.Empty);
}
public static IEnumerable<string> Like(this IEnumerable<string> source, string expression)
{
return (from s in source where s.Like(expression) select s);
}
不幸的是,我不认为这样做是容易的,但这可能是行之有效的:
var a = from t in Db.Tests
let i1 = t.Name.IndexOf("test")
let i2 = t.Name.IndexOf(".doc")
where i1 != -1 && i2 != -1 && i1 < i2
select t;
方法链中的等同:
Db.Tests.Select(t => new {t, i1 = t.Name.IndexOf("test")}).Select(
@t1 => new {@t1, i2 = @t1.t.Name.IndexOf(".doc")}).Where(
@t1 => @t1.@t1.i1 != -1 && @t1.i2 != -1 && @t1.@t1.i1 < @t1.i2).Select(@t1 => @t1.@t1.t);
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...