i have 2 lists, 1 list of equipment , 1 list of workflowitems equipment property.  equipment property within list<workflowitem> list has 1 of it's values hydrated, processid.  list<equipment> has 2 properties hydrated, processid , name.  want hydrate list<workflowitem>.equipment.name value single equipment record in list<equipment>
this linq query below select generic item out doing i'm looking for, rather fill in original list.
var list = item in workflowitems            join equipment in barcodeequipmentlist on                               item.equipment.processid equals equipment.processid            select new             {                 processid = item.equipment.processid,                 equipmentname = equipment.name             };   edit list going relatively small, doing fine (aside fact this not work)
workflowitems.foreach(x => x.equipment = e in barcodeequipmentlist                                e.process.id == x.equipment.process.id                                select e                            );   ...final edit
but work:
workflowitems.foreach(x => x.equipment = barcodeequipmentlist                                            .where(e => e.process.id == x.equipment.process.id)                                            .firstordefault());      
this piece of code should match needs:
public class equipment {     public int processid { get; set; }     public string name { get; set; } }  public class workflowitem {     public equipment { get; set; }      public void loadequipmentfrom(ienumerable<equipment> cache){         var equipment = cache.firstordefault(e => e.processid == equipment.processid);         if(equipment != null)             equipment.name = equipment.name;     } }   you assign instance cache existing one, wouldn't matter since both must have same identifier equipment = equipment;. easier if have more properties set. optimize further use idictionary<int, equipment> instead of ienumerable<equipment>, because you'll reading collection often.
i'm guessing implementing kind of orm, in case can give advice: "there out there that'll fit needs.".
Comments
Post a Comment