Reputation: 749
I'm new to LINQ and I'm not sure how to retrieve data from multiple tables from my SQL server database, here's the query:
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()
The database uses the variable connection
How can I do this?
Upvotes: 2
Views: 1248
Reputation: 5311
Linq is very similar to sql, just a little backwards.
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.Col1... cp.ColN, tsp.Action, tsp.CurrencyPair }
Upvotes: 0
Reputation: 19026
Your sql query would be something like this in 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
};
Upvotes: 2