3
Is there any way to optimize the code below so that you search the forms that have the maximum version according to the IdCentroCusto?
In the code below I’m doing the grouping and catching the CM.Max(d => d.Versao) to fetch the correct form self.
var Formularios = qrFormularios
.GroupBy(F => new { F.IdCentroCusto, F.Versao })
.Select(CM => new
{
Formulario = qrFormularios.FirstOrDefault(n => n.Versao == CM.Max(d => d.Versao) && n.IdCentroCusto == CM.Key.IdCentroCusto),
})
.ToList();
You would need a query to return all the form fields to me.
[Serializable, Table("tb_Formularios")]
public partial class rtb_Formularios
{
[Key]
public Int32 IdFormulario { get; set; }
public Int32 IdModFormulario { get; set; }
[MaxLength(100)]
public String TituloFormulario { get; set; }
public Int32 Vigencia { get; set; }
public Int32 IdUsuario { get; set; }
public Int32 IdCentroCusto { get; set; }
public Int32 Versao { get; set; }
public Int32? IdLogStatus { get; set; }
public Int32 IdPassoWorkflow { get; set; }
public DateTime? DtTransmisao { get; set; }
public DateTime DtInclusao { get; set; }
[Timestamp]
public Byte[] SeqAlteracao { get; set; }
[NotMapped]
public Int32 PKValue
{
get { return IdFormulario; }
}
}
perfect vlw...
– Marco Souza