我有一个名为attraction
的表,它有一个id
列,它是表type
的{{1}}的复合键。
吸引力:id,name,city
价格:id,类型,价格
如何在Visual Studio中按price
在一行中选择这样的数据:
linQ
答案 0 :(得分:0)
You want to access anonymous type to some kind of object and to acheive this you can try like
declare array of
var data= new[] { new
{
Id= 0,
Name = "",
City = "",
Price1 = 0,
Price2 = 0,
} }.ToList();
then you can write query like
data = (from a in attraction
join p in price on a.Id equals p.Id
select new
{
Id= a.Id,
Name = a.Name,
City = a.City,
Price1 = a.Price,
Price2 = p.Price,
}).ToList();
Try above