comparison Source/Data/Linq/Builder/TableAttributeBuilder.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 TableAttributeBuilder : MethodCallBuilder
9 {
10 protected override bool CanBuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
11 {
12 return methodCall.IsQueryable("TableName", "DatabaseName", "OwnerName");
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
19 var table = (TableBuilder.TableContext)sequence;
20 var value = (string)((ConstantExpression)methodCall.Arguments[1]).Value;
21
22 switch (methodCall.Method.Name)
23 {
24 case "TableName" : table.SqlTable.PhysicalName = value; break;
25 case "DatabaseName" : table.SqlTable.Database = value; break;
26 case "OwnerName" : table.SqlTable.Owner = value; break;
27 }
28
29 return sequence;
30 }
31
32 protected override SequenceConvertInfo Convert(
33 ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo, ParameterExpression param)
34 {
35 return null;
36 }
37 }
38 }