Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The method should get the query back based on date between 01-06-2018 and 31-12-2018
what i have tried so far is right and give me back what i want but my problem how to set the date .i have a Datetime Property :
public DateTime Order_Date { get; set; }


so i should do the next :
where ph.oder_date "01-06-2018" && ph.order_date "31-12-2018"
i need help to set that insaid my query because im getting erro somehow

What I have tried:

var query = (from ph in _webshopDbContext.FXXLPurchaseHeaders
                        join pl in _webshopDbContext.FXXLPurchaseLines on ph.No_ equals pl.Document_No_
                        orderby pl.Size, pl.Colour
                        where pl.Brand == "CUBE" && ph.Ship_to_Name_2 == "Zentrallager"
                        select new LoadResults
                        {
                            GetBrand = pl.Brand,
                            GetDescription = pl.Description,
                            GetSize = pl.Size,
                            GetColour = pl.Colour,
                            GetQuantity = pl.Quantity,
                            GetNumber = pl.No_,
                            GetShipToName = ph.Ship_to_Name,
                            GetShipName2 = ph.Ship_to_Name_2,

                        });
           return query.ToList();
Posted
Updated 13-Sep-19 5:35am

Try this:
C#
var minDateInclusive = new DateTime(2018, 6, 1);
var maxDateExclusive = new DateTime(2019, 1, 1);

var query = from ph in _webshopDbContext.FXXLPurchaseHeaders
            join pl in _webshopDbContext.FXXLPurchaseLines on ph.No_ equals pl.Document_No_
            where pl.Brand == "CUBE" 
                  && ph.Ship_to_Name_2 == "Zentrallager"
                  && ph.Order_Date >= minDateInclusive
                  && ph.Order_Date < maxDateExclusive
            orderby pl.Size, pl.Colour
            select new LoadResults ...
 
Share this answer
 
Comments
[no name] 23-Sep-19 5:28am    
Sorry i just read it now i was offline
thanks a lot it helped me
 
Share this answer
 
Comments
[no name] 13-Sep-19 11:19am    
so why it gives me no result with this Query :
var query = (from ph in _webshopDbContext.FXXLPurchaseHeaders

join pl in _webshopDbContext.FXXLPurchaseLines on ph.No_
equals pl.Document_No_
where pl.Brand == "CUBE" && ph.Ship_to_Name_2 == "Zentrallager" &&
ph.Order_Date.Year == 2018 && ph.Order_Date.Month == 6
orderby pl.Size, pl.Colour


and it gives me result if i remove (&& ph.Order_Date.Month == 6)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900