我有一个问题
var QP = (from a in QProductAllInfo select new { a.Id, a.Title, a.FullTitle}).Distinct();
Run Code Online (Sandbox Code Playgroud)
结果是:
我需要结果:
List<int> ListIdProducts = new List<int>();
var IdProductKey = from a in me.ProductKeywords where a.Keyword == item.Id select a;
foreach (var item2 in IdProductKey)
{
ListIdProducts.Add(item2.Product.Value);
}
Run Code Online (Sandbox Code Playgroud)
结果是:5 6 7 5 2 5
我需要得到以下5 = 3,6 = 1,7 = 1,2 = 1
我有一个代码:
string[] sizes = new string[] {"1","11","2","22","200","222", null, "105", "101", "102", "103", "90" };
try
{
var size = from x in sizes
orderby x.Length, x
select x;
foreach (var p in size)
{
Console.WriteLine(p);
}
Console.Read();
}
catch (NullReferenceException)
{
}
Run Code Online (Sandbox Code Playgroud)
我如何在x.Length中捕获null,并继续执行代码?
在sql我有查询
select * from table where id in (5,7,8)
Run Code Online (Sandbox Code Playgroud)
在LINQ查询中如何做到这一点?