public QueryCategoriesResult.TResult[] QueryCategories(QueryCategoriesParameter param) { using (var context = base.CreateContext()) { var q = from t in context.NewsCategories where t.AppID == param.AppID && (string.IsNullOrEmpty(param.Name) || t.Name == param.Name) orderby t.Sort select new QueryCategoriesResult.TResult { RowID = t.RowID, ParentID = t.ParentID, Name = t.Name, Sort = t.Sort, Level = t.Level, Path = t.Path, SEO_Keyword = t.SEO_Keyword, SEO_Description = t.SEO_Description }; if (param.ParentID != null) { if (param.DeepQuery) { var childID = GetDeepChildID(param.ParentID.Value); q = q.Where(t => childID.Contains(t.RowID)); } else { q = q.Where(t => t.ParentID == param.ParentID); } } return(q.ToArray()); } }
public QueryCategoriesResult QueryCategories(QueryCategoriesParameter param) { var result = new QueryCategoriesResult(); var repository = new NewsRepository(); result.ResultSet = repository.QueryCategories(param); return(result); }