0
|
1 using System;
|
|
2 using System.Collections.Generic;
|
|
3 using System.Linq;
|
|
4 using System.Linq.Expressions;
|
|
5 using System.Reflection;
|
|
6
|
|
7 using BLToolkit.Data.Sql;
|
|
8
|
|
9 namespace BLToolkit.Data.Linq
|
|
10 {
|
|
11 [SerializableAttribute]
|
|
12 [AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
|
|
13 public class TableExpressionAttribute : TableFunctionAttribute
|
|
14 {
|
|
15 public TableExpressionAttribute(string expression)
|
|
16 : base(expression)
|
|
17 {
|
|
18 }
|
|
19
|
|
20 public TableExpressionAttribute(string expression, params int[] argIndices)
|
|
21 : base(expression, argIndices)
|
|
22 {
|
|
23 }
|
|
24
|
|
25 public TableExpressionAttribute(string sqlProvider, string expression)
|
|
26 : base(sqlProvider, expression)
|
|
27 {
|
|
28 }
|
|
29
|
|
30 public TableExpressionAttribute(string sqlProvider, string expression, params int[] argIndices)
|
|
31 : base(sqlProvider, expression, argIndices)
|
|
32 {
|
|
33 }
|
|
34
|
|
35 protected new string Name
|
|
36 {
|
|
37 get { return base.Name; }
|
|
38 }
|
|
39
|
|
40 public string Expression
|
|
41 {
|
|
42 get { return base.Name; }
|
|
43 set { base.Name = value; }
|
|
44 }
|
|
45
|
|
46 public override void SetTable(SqlTable table, MemberInfo member, IEnumerable<Expression> arguments, IEnumerable<ISqlExpression> sqlArgs)
|
|
47 {
|
|
48 table.SqlTableType = SqlTableType.Expression;
|
|
49 table.Name = Expression ?? member.Name;
|
|
50 table.TableArguments = ConvertArgs(member, sqlArgs.ToArray());
|
|
51 }
|
|
52 }
|
|
53 }
|