public Tag GetByID(Guid id, ModelGetNavigtorOptions getParentOprions, ModelGetNavigtorOptions getChildrenOptions) { Tag res = null; DbQuery <Tag> tagQuery; Expression <Func <Tag, bool> > predicate = (tag => tag.ID == id); if (getParentOprions == ModelGetNavigtorOptions.GetNavigatorRecursive) { tagQuery = this.dbSet.Include("ParentTag"); } else { tagQuery = this.dbSet; } if (getChildrenOptions == ModelGetNavigtorOptions.GetNavigatorRecursive) { tagQuery.Include("TagList"); } res = tagQuery.First(predicate); if (getParentOprions == ModelGetNavigtorOptions.GetNavigator) { // EF is fichsa res.ParentTag?.ToString(); } if (getChildrenOptions == ModelGetNavigtorOptions.GetNavigator) { res.TagList = res.TagList ?? new List <Tag>(); } return(res); }
public EntityResponse <Tag> GetByID(Guid Id, ModelGetNavigtorOptions getParent = ModelGetNavigtorOptions.None, ModelGetNavigtorOptions getChildren = ModelGetNavigtorOptions.None) { EntityResponse <Tag> res = new EntityResponse <Tag>(); try { res.Entity = this._rep.GetByID(Id, getParent, getChildren); res.Success = true; } catch (Exception e) { res.Success = false; res.Message = e.Message; } return(res); }