示例#1
0
        public async Task <LogDescriptionSubSearchModel> GetLogDescriptionByLogIdAsync(int logId)
        {
            var log = await _context.Logs.Include(l => l.LogDescription)
                      .Where(l => l.LogId == logId).FirstOrDefaultAsync();

            var logDescription       = log == null ? null : log.LogDescription;
            var logDescriptionSearch = LogDescriptionOperator.SetLogDescriptionSubSearchModel(logDescription);

            return(logDescriptionSearch);
        }
        public LogDescriptionSearchModel FindById(int logDescriptionId)
        {
            var result = _context.LogDescriptions
                         .Where(v => v.LogDescriptionId == logDescriptionId);

            result = (IQueryable <LogDescription>)ExpandOperator.ExpandRelatedEntities <LogDescription>(result);

            var logDescription       = result.FirstOrDefault();
            var logDescriptionSearch = LogDescriptionOperator.SetLogDescriptionSearchModelCascade(logDescription);

            return(logDescriptionSearch);
        }
        public IEnumerable <LogDescriptionSearchModel> GetAll()
        {
            var queryData = from L in _context.LogDescriptions
                            select L;

            var result = QueryOperate <LogDescription> .Execute(queryData);

            result = (IQueryable <LogDescription>)ExpandOperator.ExpandRelatedEntities <LogDescription>(result);

            //以下执行完后才会去数据库中查询
            var logDescriptions       = result.ToList();
            var logDescriptionsSearch = LogDescriptionOperator.SetLogDescriptionSearchModelCascade(logDescriptions);

            return(logDescriptionsSearch);
        }