comparison Source/Data/Linq/Builder/DistinctBuilder.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.Linq.Expressions;
3
4 namespace BLToolkit.Data.Linq.Builder
5 {
6 using BLToolkit.Linq;
7
8 class DistinctBuilder : MethodCallBuilder
9 {
10 protected override bool CanBuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
11 {
12 return methodCall.IsQueryable("Distinct");
13 }
14
15 protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
16 {
17 var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
18 var sql = sequence.SqlQuery;
19
20 if (sql.Select.TakeValue != null || sql.Select.SkipValue != null)
21 sequence = new SubQueryContext(sequence);
22
23 sequence.SqlQuery.Select.IsDistinct = true;
24 sequence.ConvertToIndex(null, 0, ConvertFlags.All);
25
26 return sequence;
27 }
28
29 protected override SequenceConvertInfo Convert(
30 ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo, ParameterExpression param)
31 {
32 return null;
33 }
34 }
35 }