是否可以编写linq将结果放入其他对象而不使用下面的组,
SELECT test.name, test.date, test.flag, cmd, root, result
into [streamanalyticsoutput] from [streamanalyticsinput]
以下是带有Group的Linq查询,
var query2 = from c in _context.MCTargets
group c by c.MarketingCampaignID into g
select new
{
StartDate = d1,
EndDate = d2
};
答案 0 :(得分:0)
看到你的sql根本不需要分组 - 只是对不同类型对象的投影
var result = from c in _context.MCTargets
select new {
// Project here only the fields you want from the MCTargets
Name = c.Name,
Date = c.Date,
Flag = c.Flag
};
在这种情况下,它只是投射到匿名类型,但如果你有一个特定的类,那么使用select new YourClass { ... }
答案 1 :(得分:0)
这将选择所有字段:
var query2 = (from c in _context.MCTargets
select c).ToList();
然后,您可以使用所需的MCTarget
对象的多个属性。
如果由于某种原因只想选择某些列,则可以创建匿名对象:
var query2 = (from c in _context.MCTargets
select new { Name = c.Name, Date = c.Date}).ToList();
...或者你可以创建一个新类并设置这个类的属性:
var query2 = (from c in _context.MCTargets
select new YourClass { Name = c.Name, Date = c.Date}).ToList();