我有一个名为attraction
的表,它有一个id
列,它是一个带有表price的
.type
的复合键
Attraction: id, name, city
price: id, type, price
如何在 Visual Studio 中通过 linQ
在一行中选择这样的数据:
id, name, city, type1_price, type2_price
最佳答案
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
关于mysql - 如何使用linq命令选择此数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37790459/