diff Source/Data/Linq/TableExpressionAttribute.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/Data/Linq/TableExpressionAttribute.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+
+using BLToolkit.Data.Sql;
+
+namespace BLToolkit.Data.Linq
+{
+	[SerializableAttribute]
+	[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
+	public class TableExpressionAttribute : TableFunctionAttribute
+	{
+		public TableExpressionAttribute(string expression)
+			: base(expression)
+		{
+		}
+
+		public TableExpressionAttribute(string expression, params int[] argIndices)
+			: base(expression, argIndices)
+		{
+		}
+
+		public TableExpressionAttribute(string sqlProvider, string expression)
+			: base(sqlProvider, expression)
+		{
+		}
+
+		public TableExpressionAttribute(string sqlProvider, string expression, params int[] argIndices)
+			: base(sqlProvider, expression, argIndices)
+		{
+		}
+
+		protected new string Name
+		{
+			get { return base.Name; }
+		}
+
+		public string Expression
+		{
+			get { return base.Name;  }
+			set { base.Name = value; }
+		}
+
+		public override void SetTable(SqlTable table, MemberInfo member, IEnumerable<Expression> arguments, IEnumerable<ISqlExpression> sqlArgs)
+		{
+			table.SqlTableType   = SqlTableType.Expression;
+			table.Name           = Expression ?? member.Name;
+			table.TableArguments = ConvertArgs(member, sqlArgs.ToArray());
+		}
+	}
+}