0
Making order system, I have several warehouses, let’s assume I have to compare 2 warehouses that have shorter delivery time using entityframework,how would I do that? I’m trying to do more it just returns the last value consulted, but not the smallest. in the code below, I have a foreach that runs through 2 warehouses and in the end it would return me only the with 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);
}
Armazen
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; }
}