using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Sleis.Models { public class UnitProcessControlDevice : BaseModel { public virtual List ControlDevices { get; set; } public virtual List EntityControlDevices { get; set; } public UnitProcessControlDevice() { ControlDevices = new List(); EntityControlDevices = new List(); } public void SortByIndex() { ControlDevices = (from d in ControlDevices join e in EntityControlDevices on d.Id equals e.ControlDeviceId orderby e.SequenceNumber ascending select d).ToList(); } public override void SetContext(string parentContext) { if (ControlDevices != null) ControlDevices.ForEach(x => x.SetContext(parentContext)); if (EntityControlDevices != null) EntityControlDevices.ForEach(x => x.SetContext(parentContext)); } } }