My class:
public class AvailabilityDataWithoutAging
{
public string BranchPlant { get; set; }
public string Location { get; set; }
public string ItemCode { get; set; }
public string ItemDescription { get; set; }
public int PiecesPerPalletMaster { get; set; }
public int NumberOfLots { get; set; }
public int NumberOfPalletsConversion { get; set; }
public int AvailablePrimary { get; set; }
public int TempPrimary { get; set; }
public int BlankPrimary { get; set; }
public int HoldAutomaticPrimary { get; set; }
public int HoldSpecificPrimary { get; set; }
public void CalculatePrimaryFromConversion()
{
NumberOfPalletsConversion = AvailablePrimary/PiecesPerPalletMaster;
}
}
I want to use method CalculatePrimaryFromConversion within this:
retValue = _data
.GroupBy(av => new {av.limcu, av.lilocn, av.imlitm})
.Select(av => new AvailabilityDataWithoutAging
{
BranchPlant = av.Key.limcu,
Location = av.Key.lilocn,
ItemCode = av.Key.imlitm,
ItemDescription = av.Max(s => s.imdsc),
PiecesPerPalletMaster = Convert.ToInt32(_JDE8dal.GetF41002Conversion(av.Max(s=>s.liitm),"PL","EA")),
AvailablePrimary = av.Sum(s => s.lipqoh),
NumberOfLots = av.Count(s => s.lilotn.StartsWith("1")),
TempPrimary = av.Sum(s => s.lilotn=="TEMP" ? s.lipqoh : 0),
BlankPrimary = av.Sum(s => s.lilotn == "" ? s.lipqoh : 0),
HoldAutomaticPrimary = 0,
HoldSpecificPrimary = 0
}).ToList();
Is there a way to do it?
ADDITIONAL INFO:
I do not want to do it only within select, this was an example. I want to be able to do it on the fly while i instantiate the class. Sorry for the confusion
NumberOfPalletsConversion?