} // /// <summary> /// Or just get all and let caller sort the data /// </summary> /// <param name="parentId"></param> /// <returns></returns> public static List <ThisEntity> GetAll(int parentId) { var entity = new ThisEntity(); var list = new List <ThisEntity>(); if (parentId < 1) { return(list); } try { using (var context = new EntityContext()) { //there could be multiple relationships for a parent and component List <DBEntity> results = context.Entity_HasPathway .Where(s => s.EntityId == parentId) .OrderBy(s => s.PathwayRelationshipTypeId) .ThenBy(s => s.Pathway.Name) // .ToList(); if (results != null && results.Count > 0) { foreach (var from in results) { if (from != null && from.Id > 0) { entity.Id = from.Id; entity.EntityId = from.EntityId; entity.PathwayId = from.PathwayId; entity.PathwayRelationshipTypeId = from.PathwayRelationshipTypeId > 0 ? from.PathwayRelationshipTypeId : 0; if (IsValidDate(from.Created)) { entity.Created = ( DateTime )from.Created; } entity.PathwayName = from.Pathway.Name; //to.Credential = from.Credential; entity.Pathway = new Pathway(); PathwayManager.MapFromDB(from.Pathway, entity.Pathway, false); } } } } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".GetAll"); } return(list); } //
/// <summary> /// Get all components for the provided entity /// The returned entities are just the base /// </summary> /// <param name="parentUid"></param> /// <returns></returns> public static List <Pathway> GetAll(Guid parentUid, bool includingComponents = false) { List <Pathway> list = new List <Pathway>(); Pathway entity = new Pathway(); Entity parent = EntityManager.GetEntity(parentUid); LoggingHelper.DoTrace(7, string.Format("Entity_Pathway_GetAll: parentUid:{0} entityId:{1}, e.EntityTypeId:{2}", parentUid, parent.Id, parent.EntityTypeId)); try { using (var context = new EntityContext()) { List <DBEntity> results = context.Entity_HasPathway .Where(s => s.EntityId == parent.Id) .OrderBy(s => s.Pathway.Name) //not suire .ToList(); if (results != null && results.Count > 0) { foreach (DBEntity item in results) { //actually the relationship type is not applicable in the component entity = new Pathway() { PathwayRelationshipTypeId = item.PathwayRelationshipTypeId }; //not sure if we will have variances in what is returned PathwayManager.MapFromDB(item.Pathway, entity, includingComponents); list.Add(entity); } } return(list); } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".Entity_Pathway_GetAll"); } return(list); }