Doing order system, I have several warehouses, let's suppose I have to compare 2 warehouses that have shorter lead times by using entityframework, how would I do that? I'm trying to do more but it only returns the last query value, but not the least. in the code below, I have a foreach that runs through 2 warehouses and in the end it would only return me with the shorter delivery time
foreach (var item2 in lstDeposito)
{
Armazem arm = db.Armazem.Find(item2.Deposito.ArmazemId);
var de = db.Armazem.Where(x => x.Id == arm.Id).Min(x => x.Prazo);
int menorprazo = Convert.ToInt32(de);
}
Store
public class Armazem
{
public int Id { get; set; }
[Required]
[StringLength(50)]
public string Nome { get; set; }
public int Prazo { get; set; }
public virtual ICollection<Deposito> Deposito { get; set; }
}