I have this Linq Query I run a search function on (DateFrom and DateTo are dateTime objects):
var result = from x in DbContext.Transaction_Groups
where (x.Date_Created >= DateFrom && x.Date_Created <= DateTo)
select x;
And these are my tables:
I'm trying to join these two tables together so that I can use the .Transaction_Date_Time
instead of the .Date_Created function
that's in my query.
My query is trying to determine all the rows between the DateFrom
(user selected value) and the DateTo
(Another user selected value).
var result = from transgroup in DbContext.Transaction_Groups
join cashDep in DbContext.CashDeposit
on transgroup.Group_ID equals cashDep.Group_ID
where (cashDep.Transaction_Date_Time >= DateFrom
&& cashDep.Transaction_Date_Time <= DateTo)
select transgroup
Untested, but should work. indentation for clarity.
Do you want to join by Group_ID?
var result = from x in DbContext.Transaction_Groups
join tran in DbContext.CashDeposit on x.Group_ID equals tran.Group_ID
where (tran.Transaction_Date_Time >= DateFrom && tran.Transaction_Date_Time <= DateTo)
select tran;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.