I have the following T-SQL query which I'm trying to convert into C# code:
SELECT
*, DATEFROMPARTS(Jaar, Maand, 1)
FROM
EAN_Budget_Meetdata_Factuur
WHERE
EID = 1 AND
Bron = 'B' AND
DATEFROMPARTS(Jaar, Maand, 1) BETWEEN '20161101' AND '20170101'
The table contains a column Year and Month, and I'm querying the table based on two known DateTimes (a period).
The query is meant to retrieve the table rows that apply to this period based on the years and months between the two DateTimes.
What is the best way to convert this query into C#? I've so far come up with the following, without success:
var query = from b in CT2.EAN_Budget_Meetdata_Factuur
let JaarTest = b.Jaar + "-" + b.Maand + "-01"
where
b.EID == 1 &&
b.Bron == "B" &&
JaarTest == "something"
select new
{
JaarTest = b.Jaar + "-" + b.Maand + "-01"
};