Esempio n. 1
0
            private string FilterDtoStudents(string filterExpressionForDto)
            {
                var filter        = FilterInfo.Parse(filterExpressionForDto);
                var studentMapper = new ObjectMapper <Student, StudentDto>();

                studentMapper.Append(p => p.TName, p => p.Name);
                studentMapper.Append(p => p.TAge, p => p.Age);
                studentMapper.Append(p => p.TId, p => p.Id);
                studentMapper.Append(p => p.THeight, p => (decimal?)p.Height);
                studentMapper.Append(p => p.TAddress, p => p.Address);

                var scoreMapper = new ObjectMapper <ScoreRecord, ScoreDto>();

                scoreMapper.Append(p => p.TClassName, p => p.ClassName);
                scoreMapper.Append(p => p.TScore, p => p.Score);
                scoreMapper.Append(p => p.TExam, p => p.Exam as IExam);
                studentMapper.AppendCollection(p => p.TScores, p => p.Scores, scoreMapper);

                var ids = Students.AsQueryable().DoFilter(filter)
                          .Select(p => p.Id);

                return(string.Join(",", ids));
            }
Esempio n. 2
0
            private string FilterDtoStudents(string filterExpressionForDto)
            {
                var filter        = FilterInfo.Parse(filterExpressionForDto);
                var studentMapper = new ObjectMapper <Student, StudentDto>();

                studentMapper.Append(p => p.TName, p => p.Name);
                studentMapper.Append(p => p.TAge, p => p.Age);
                studentMapper.Append(p => p.TId, p => p.Id);
                studentMapper.Append(p => p.THeight, p => (decimal?)p.Height);
                studentMapper.Append(p => p.TAddress, p => p.Address);

                var scoreMapper = new ObjectMapper <ScoreRecord, ScoreDto>();

                scoreMapper.Append(p => p.TClassName, p => p.ClassName);
                scoreMapper.Append(p => p.TScore, p => p.Score);
                scoreMapper.Append(p => p.TExam, p => p.Exam as IExam);
                studentMapper.AppendCollection(p => p.TScores, p => p.Scores, scoreMapper);

                var ids = dataContext1.Students.DoFilter(filter, studentMapper).OrderBy(p => p.Id)
                          .Select(p => p.Id);

                Console.WriteLine(ids.ToQueryString());
                return(string.Join(",", ids));
            }