I have two tables like this
Table Product
ProductId - int <PK>
ProductExpiry - TimeDate
AlertOfExpiry - int
ProductTypeId - int<Fk>
Table ProductType
ProudctTypeId - int <PK>
Name - varchar(50)
Now I want to get a list of products that will expire soon. So what I am trying to do is
Say todays date is today August 24 and an expiry date of a product is 28 and a 4 day expiry date is set.
So 28 - 4 = 24 (show in list on 24th)
But I also want to get the "Name" to be included with the output that is in the ProductTypeTable.
This is what I have so far.
var grab = dbContext.Product.Where(u => u.ProductExpiry.addDays(Convert.ToDouble(u.AlertOfExpiry)) >= DateTime.Now)
So first I am not sure how to get the minus(-) in the addDays since it is already so messy.
I then don't know how to go from there and look at those found results and go to the ProductType and get the names.
I think the where part would be like (grab.ProducttypeId == grab.ProductTypeid) // grab the names somehow.
So can anyone help me out. Also how can I make it a bit cleaner?