Mercurial > pub > bltoolkit
diff Source/Data/Linq/SqlExpressionAttribute.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/SqlExpressionAttribute.cs Thu Mar 27 21:46:09 2014 +0400 @@ -0,0 +1,55 @@ +using System; +using System.Reflection; + +namespace BLToolkit.Data.Linq +{ + using Data.Sql; + using Reflection; + + [SerializableAttribute] + [AttributeUsageAttribute(AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = true, Inherited = false)] + public class SqlExpressionAttribute : SqlFunctionAttribute + { + public SqlExpressionAttribute(string expression) + : base(expression) + { + Precedence = Data.Sql.Precedence.Primary; + } + + public SqlExpressionAttribute(string expression, params int[] argIndices) + : base(expression, argIndices) + { + Precedence = Data.Sql.Precedence.Primary; + } + + public SqlExpressionAttribute(string sqlProvider, string expression) + : base(sqlProvider, expression) + { + Precedence = Data.Sql.Precedence.Primary; + } + + public SqlExpressionAttribute(string sqlProvider, string expression, params int[] argIndices) + : base(sqlProvider, expression, argIndices) + { + Precedence = Data.Sql.Precedence.Primary; + } + + protected new string Name + { + get { return base.Name; } + } + + public string Expression + { + get { return base.Name; } + set { base.Name = value; } + } + + public int Precedence { get; set; } + + public override ISqlExpression GetExpression(MemberInfo member, params ISqlExpression[] args) + { + return new SqlExpression(TypeHelper.GetMemberType(member), Expression ?? member.Name, Precedence, ConvertArgs(member, args)); + } + } +}