我是 LINQ 新手,不确定如何从 SQL Server 数据库的多个表中检索数据,查询如下:
SELECT cp.*, tsd.Action, tsd.CurrencyPair
from TradeStatsData tsd, CalculatedPrices cp
where tsd.TradeID = cp.TradeID and cp.Price is null and cp.ActiveTime < GETDATE()
数据库使用变量连接
我该怎么做?
最佳答案
您的 sql 查询在 LINQ 中将类似于以下内容:
var result = from tsd in TradeStatsData
join cp in CalculatedPrices on tsd.TradeID equals cp.TradeID
where cp.Price == null && cp.ActiveTime < DateTime.Now
select new
{
CP = cp,
Action = tsd.Action,
CurrencyPair = tsd.CurrencyPair
};
关于c# - 在 LINQ to SQL 查询中从多个表检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21588468/