/// <summary> /// Полность загружает директиву делая запрос по заданному ID /// </summary> /// <param name="itemId"></param> /// <param name="directiveType"></param> /// <param name="loadChild"></param> public Directive GetDirectiveById(Int32 itemId, DirectiveType directiveType, bool loadChild = true) { if (directiveType == null) { directiveType = DirectiveType.AirworthenessDirectives; } var qrs = DirectiveQueries.GetSelectQueryById(itemId, directiveType, loadChild: loadChild); var directive = _loader.GetObjectListAll <Directive>(qrs, true).FirstOrDefault(); if (directive == null) { return(null); } var itemsRelations = _itemsRelationsDataAccess.GetRelations(directive.ItemId, directive.SmartCoreObjectType.ItemId); var fileIds = directive.Files.Where(i => i.FileId.HasValue).Select(i => i.FileId.Value); if (fileIds.Any()) { var files = _newLoader.GetObjectList <AttachedFileDTO, AttachedFile>(new Filter("ItemId", values: fileIds)); foreach (var file in directive.Files) { var f = files.FirstOrDefault(i => i.ItemId == file.FileId)?.GetCopyUnsaved(false); if (f == null) { continue; } f.ItemId = file.FileId.Value; file.File = (AttachedFile)f; } } directive.ItemRelations.AddRange(itemsRelations); return(directive); // Примечание - загрузка всех связанных данных должна идти вместе с выставлением Parent }
/// <summary> /// Полность загружает директиву делая запрос по заданному ID /// </summary> /// <param name="itemId"></param> /// <param name="directiveType"></param> /// <param name="loadChild"></param> public Directive GetDirectiveById(Int32 itemId, DirectiveType directiveType, bool loadChild = true) { if (directiveType == null) { directiveType = DirectiveType.AirworthenessDirectives; } var qrs = DirectiveQueries.GetSelectQueryById(itemId, directiveType, loadChild: loadChild); var directive = _loader.GetObjectListAll <Directive>(qrs, true).FirstOrDefault(); if (directive == null) { return(null); } var itemsRelations = _itemsRelationsDataAccess.GetRelations(directive.ItemId, directive.SmartCoreObjectType.ItemId); directive.ItemRelations.AddRange(itemsRelations); return(directive); // Примечание - загрузка всех связанных данных должна идти вместе с выставлением Parent }