comparison Source/Data/Linq/Expressions.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.Collections.Generic;
3 using System.Data.Linq;
4 using System.Linq.Expressions;
5 using System.Reflection;
6 using System.Text;
7
8 #region ReSharper disables
9 // ReSharper disable RedundantTypeArgumentsOfMethod
10 // ReSharper disable RedundantCast
11 // ReSharper disable PossibleInvalidOperationException
12 // ReSharper disable CSharpWarnings::CS0693
13 // ReSharper disable RedundantToStringCall
14 #endregion
15
16 namespace BLToolkit.Data.Linq
17 {
18 using B = Boolean;
19 using C = Char;
20 using S = String;
21 using I = Int32;
22 using O = Object;
23 using D = DateTime;
24 using T = TimeSpan;
25 using F = Double;
26 using M = Decimal;
27
28 public static class Expressions
29 {
30 #region MapMember
31
32 public static void MapMember(MemberInfo memberInfo, LambdaExpression expression)
33 {
34 MapMember("", memberInfo, expression);
35 }
36
37 public static void MapMember(string providerName, MemberInfo memberInfo, LambdaExpression expression)
38 {
39 Dictionary<MemberInfo,LambdaExpression> dic;
40
41 if (!_members.TryGetValue(providerName, out dic))
42 _members.Add(providerName, dic = new Dictionary<MemberInfo,LambdaExpression>());
43
44 dic[memberInfo] = expression;
45 }
46
47 public static void MapMember(Expression<Func<object>> memberInfo, LambdaExpression expression)
48 {
49 MapMember("", M(memberInfo), expression);
50 }
51
52 public static void MapMember(string providerName, Expression<Func<object>> memberInfo, LambdaExpression expression)
53 {
54 MapMember(providerName, M(memberInfo), expression);
55 }
56
57 public static void MapMember<T>(Expression<Func<T,object>> memberInfo, LambdaExpression expression)
58 {
59 MapMember("", M(memberInfo), expression);
60 }
61
62 public static void MapMember<T>(string providerName, Expression<Func<T,object>> memberInfo, LambdaExpression expression)
63 {
64 MapMember(providerName, M(memberInfo), expression);
65 }
66
67 public static void MapMember<TR> (string providerName, Expression<Func<TR>> memberInfo, Expression<Func<TR>> expression) { MapMember(providerName, ReflectionHelper.MemeberInfo(memberInfo), expression); }
68 public static void MapMember<TR> ( Expression<Func<TR>> memberInfo, Expression<Func<TR>> expression) { MapMember("", ReflectionHelper.MemeberInfo(memberInfo), expression); }
69 public static void MapMember<T1,TR> (string providerName, Expression<Func<T1,TR>> memberInfo, Expression<Func<T1,TR>> expression) { MapMember(providerName, ReflectionHelper.MemeberInfo(memberInfo), expression); }
70 public static void MapMember<T1,TR> ( Expression<Func<T1,TR>> memberInfo, Expression<Func<T1,TR>> expression) { MapMember("", ReflectionHelper.MemeberInfo(memberInfo), expression); }
71 public static void MapMember<T1,T2,TR> (string providerName, Expression<Func<T1,T2,TR>> memberInfo, Expression<Func<T1,T2,TR>> expression) { MapMember(providerName, ReflectionHelper.MemeberInfo(memberInfo), expression); }
72 public static void MapMember<T1,T2,TR> ( Expression<Func<T1,T2,TR>> memberInfo, Expression<Func<T1,T2,TR>> expression) { MapMember("", ReflectionHelper.MemeberInfo(memberInfo), expression); }
73 public static void MapMember<T1,T2,T3,TR> (string providerName, Expression<Func<T1,T2,T3,TR>> memberInfo, Expression<Func<T1,T2,T3,TR>> expression) { MapMember(providerName, ReflectionHelper.MemeberInfo(memberInfo), expression); }
74 public static void MapMember<T1,T2,T3,TR> ( Expression<Func<T1,T2,T3,TR>> memberInfo, Expression<Func<T1,T2,T3,TR>> expression) { MapMember("", ReflectionHelper.MemeberInfo(memberInfo), expression); }
75 public static void MapMember<T1,T2,T3,T4,TR> (string providerName, Expression<Func<T1,T2,T3,T4,TR>> memberInfo, Expression<Func<T1,T2,T3,T4,TR>> expression) { MapMember(providerName, ReflectionHelper.MemeberInfo(memberInfo), expression); }
76 public static void MapMember<T1,T2,T3,T4,TR> ( Expression<Func<T1,T2,T3,T4,TR>> memberInfo, Expression<Func<T1,T2,T3,T4,TR>> expression) { MapMember("", ReflectionHelper.MemeberInfo(memberInfo), expression); }
77 public static void MapMember<T1,T2,T3,T4,T5,TR>(string providerName, Expression<Func<T1,T2,T3,T4,T5,TR>> memberInfo, Expression<Func<T1,T2,T3,T4,T5,TR>> expression) { MapMember(providerName, ReflectionHelper.MemeberInfo(memberInfo), expression); }
78 public static void MapMember<T1,T2,T3,T4,T5,TR>( Expression<Func<T1,T2,T3,T4,T5,TR>> memberInfo, Expression<Func<T1,T2,T3,T4,T5,TR>> expression) { MapMember("", ReflectionHelper.MemeberInfo(memberInfo), expression); }
79
80 #endregion
81
82 #region Public Members
83
84 public static LambdaExpression ConvertMember(string providerName, MemberInfo mi)
85 {
86 Dictionary<MemberInfo,LambdaExpression> dic;
87 LambdaExpression expr;
88
89 if (Members.TryGetValue(providerName, out dic))
90 if (dic.TryGetValue(mi, out expr))
91 return expr;
92
93 if (!Members[""].TryGetValue(mi, out expr))
94 {
95 if (mi is MethodInfo && mi.Name == "CompareString" && mi.DeclaringType.FullName == "Microsoft.VisualBasic.CompilerServices.Operators")
96 {
97 lock (_members)
98 {
99 if (!Members[""].TryGetValue(mi, out expr))
100 {
101 expr = L<S,S,B,I>((s1,s2,b) => b ? string.CompareOrdinal(s1.ToUpper(), s2.ToUpper()) : string.CompareOrdinal(s1, s2));
102
103 _members[""].Add(mi, expr);
104 }
105 }
106 }
107 }
108
109 return expr;
110 }
111
112 #endregion
113
114 #region Function Mapping
115
116 #region Helpers
117
118 static MemberInfo M<T>(Expression<Func<T,object>> func)
119 {
120 return ReflectionHelper.MemeberInfo(func);
121 }
122
123 static MemberInfo M(Expression<Func<object>> func)
124 {
125 return ReflectionHelper.MemeberInfo(func);
126 }
127
128 static LambdaExpression L<TR> (Expression<Func<TR>> func) { return func; }
129 static LambdaExpression L<T1,TR> (Expression<Func<T1,TR>> func) { return func; }
130 static LambdaExpression L<T1,T2,TR> (Expression<Func<T1,T2,TR>> func) { return func; }
131 static LambdaExpression L<T1,T2,T3,TR> (Expression<Func<T1,T2,T3,TR>> func) { return func; }
132 static LambdaExpression L<T1,T2,T3,T4,TR> (Expression<Func<T1,T2,T3,T4,TR>> func) { return func; }
133 static LambdaExpression L<T1,T2,T3,T4,T5,TR> (Expression<Func<T1,T2,T3,T4,T5,TR>> func) { return func; }
134 static LambdaExpression L<T1,T2,T3,T4,T5,T6,TR> (Expression<Func<T1,T2,T3,T4,T5,T6,TR>> func) { return func; }
135
136 #endregion
137
138 static public Dictionary<string,Dictionary<MemberInfo,LambdaExpression>> Members { get { return _members; } }
139 static readonly Dictionary<string,Dictionary<MemberInfo,LambdaExpression>> _members = new Dictionary<string,Dictionary<MemberInfo,LambdaExpression>>
140 {
141 { "", new Dictionary<MemberInfo,LambdaExpression> {
142
143 #region String
144
145 { M(() => "".Length ), L<S,I> ( obj => Sql.Length(obj).Value) },
146 { M(() => "".Substring (0) ), L<S,I,S> ((obj,p0) => Sql.Substring(obj, p0 + 1, obj.Length - p0)) },
147 { M(() => "".Substring (0,0) ), L<S,I,I,S> ((obj,p0,p1) => Sql.Substring(obj, p0 + 1, p1)) },
148 { M(() => "".ContainsExactly("") ), L<S,S,I> ((obj,p0) => p0.Length == 0 ? 0 : (Sql.ContainsExactly(p0, obj) .Value) - 1) },
149 { M(() => "".IndexOf ("") ), L<S,S,I> ((obj,p0) => p0.Length == 0 ? 0 : (Sql.CharIndex(p0, obj) .Value) - 1) },
150 { M(() => "".IndexOf ("",0) ), L<S,S,I,I> ((obj,p0,p1) => p0.Length == 0 && obj.Length > p1 ? p1 : (Sql.CharIndex(p0, obj, p1 + 1).Value) - 1) },
151 { M(() => "".IndexOf ("",0,0) ), L<S,S,I,I,I>((obj,p0,p1,p2) => p0.Length == 0 && obj.Length > p1 ? p1 : (Sql.CharIndex(p0, Sql.Left(obj, p2), p1) .Value) - 1) },
152 { M(() => "".IndexOf (' ') ), L<S,C,I> ((obj,p0) => (Sql.CharIndex(p0, obj) .Value) - 1) },
153 { M(() => "".IndexOf (' ',0) ), L<S,C,I,I> ((obj,p0,p1) => (Sql.CharIndex(p0, obj, p1 + 1).Value) - 1) },
154 { M(() => "".IndexOf (' ',0,0) ), L<S,C,I,I,I>((obj,p0,p1,p2) => (Sql.CharIndex(p0, Sql.Left(obj, p2), p1) ?? 0) - 1) },
155 { M(() => "".LastIndexOf("") ), L<S,S,I> ((obj,p0) => p0.Length == 0 ? obj.Length - 1 : (Sql.CharIndex(p0, obj) .Value) == 0 ? -1 : obj.Length - (Sql.CharIndex(Sql.Reverse(p0), Sql.Reverse(obj)) .Value) - p0.Length + 1) },
156 { M(() => "".LastIndexOf("",0) ), L<S,S,I,I> ((obj,p0,p1) => p0.Length == 0 ? p1 : (Sql.CharIndex(p0, obj, p1 + 1).Value) == 0 ? -1 : obj.Length - (Sql.CharIndex(Sql.Reverse(p0), Sql.Reverse(obj.Substring(p1, obj.Length - p1))).Value) - p0.Length + 1) },
157 { M(() => "".LastIndexOf("",0,0) ), L<S,S,I,I,I>((obj,p0,p1,p2) => p0.Length == 0 ? p1 : (Sql.CharIndex(p0, Sql.Left(obj, p1 + p2), p1 + 1).Value) == 0 ? -1 : p1 + p2 - (Sql.CharIndex(Sql.Reverse(p0), Sql.Reverse(obj.Substring(p1, p2))) .Value) - p0.Length + 1) },
158 { M(() => "".LastIndexOf(' ') ), L<S,C,I> ((obj,p0) => (Sql.CharIndex(p0, obj) .Value) == 0 ? -1 : obj.Length - (Sql.CharIndex(p0, Sql.Reverse(obj)) .Value)) },
159 { M(() => "".LastIndexOf(' ',0) ), L<S,C,I,I> ((obj,p0,p1) => (Sql.CharIndex(p0, obj, p1 + 1) .Value) == 0 ? -1 : obj.Length - (Sql.CharIndex(p0, Sql.Reverse(obj.Substring(p1, obj.Length - p1))).Value)) },
160 { M(() => "".LastIndexOf(' ',0,0) ), L<S,C,I,I,I>((obj,p0,p1,p2) => (Sql.CharIndex(p0, Sql.Left(obj, p1 + p2), p1 + 1).Value) == 0 ? -1 : p1 + p2 - (Sql.CharIndex(p0, Sql.Reverse(obj.Substring(p1, p2))) .Value)) },
161 { M(() => "".Insert (0,"") ), L<S,I,S,S> ((obj,p0,p1) => obj.Length == p0 ? obj + p1 : Sql.Stuff(obj, p0 + 1, 0, p1)) },
162 { M(() => "".Remove (0) ), L<S,I,S> ((obj,p0) => Sql.Left (obj, p0)) },
163 { M(() => "".Remove (0,0) ), L<S,I,I,S> ((obj,p0,p1) => Sql.Stuff (obj, p0 + 1, p1, "")) },
164 { M(() => "".PadLeft (0) ), L<S,I,S> ((obj,p0) => Sql.PadLeft (obj, p0, ' ')) },
165 { M(() => "".PadLeft (0,' ') ), L<S,I,C,S> ((obj,p0,p1) => Sql.PadLeft (obj, p0, p1)) },
166 { M(() => "".PadRight (0) ), L<S,I,S> ((obj,p0) => Sql.PadRight (obj, p0, ' ')) },
167 { M(() => "".PadRight (0,' ') ), L<S,I,C,S> ((obj,p0,p1) => Sql.PadRight (obj, p0, p1)) },
168 { M(() => "".Replace ("","") ), L<S,S,S,S> ((obj,p0,p1) => Sql.Replace (obj, p0, p1)) },
169 { M(() => "".Replace (' ',' ') ), L<S,C,C,S> ((obj,p0,p1) => Sql.Replace (obj, p0, p1)) },
170 { M(() => "".Trim () ), L<S,S> ( obj => Sql.Trim (obj)) },
171 { M(() => "".TrimEnd () ), L<S,C[],S> ((obj,ch) => TrimRight(obj, ch)) },
172 { M(() => "".TrimStart () ), L<S,C[],S> ((obj,ch) => TrimLeft (obj, ch)) },
173 { M(() => "".ToLower () ), L<S,S> ( obj => Sql.Lower(obj)) },
174 { M(() => "".ToUpper () ), L<S,S> ( obj => Sql.Upper(obj)) },
175 { M(() => "".CompareTo ("") ), L<S,S,I> ((obj,p0) => ConvertToCaseCompareTo(obj, p0).Value ) },
176 { M(() => "".CompareTo (1) ), L<S,O,I> ((obj,p0) => ConvertToCaseCompareTo(obj, p0.ToString()).Value ) },
177
178 { M(() => string.IsNullOrEmpty ("") ), L<S,B> ( p0 => p0 == null || p0.Length == 0) },
179 { M(() => string.CompareOrdinal("","")), L<S,S,I> ((s1,s2) => s1.CompareTo(s2)) },
180 { M(() => string.CompareOrdinal("",0,"",0,0)), L<S,I,S,I,I,I> ((s1,i1,s2,i2,l) => s1.Substring(i1, l).CompareTo(s2.Substring(i2, l))) },
181 { M(() => string.Compare ("","")), L<S,S,I> ((s1,s2) => s1.CompareTo(s2)) },
182 { M(() => string.Compare ("",0,"",0,0)), L<S,I,S,I,I,I> ((s1,i1,s2,i2,l) => s1.Substring(i1,l).CompareTo(s2.Substring(i2,l))) },
183 #if !SILVERLIGHT
184 { M(() => string.Compare ("","",true)), L<S,S,B,I> ((s1,s2,b) => b ? s1.ToLower().CompareTo(s2.ToLower()) : s1.CompareTo(s2)) },
185 { M(() => string.Compare ("",0,"",0,0,true)), L<S,I,S,I,I,B,I>((s1,i1,s2,i2,l,b) => b ? s1.Substring(i1,l).ToLower().CompareTo(s2.Substring(i2, l).ToLower()) : s1.Substring(i1, l).CompareTo(s2.Substring(i2, l))) },
186 #endif
187
188 { M(() => AltStuff("",0,0,"")), L<S,I?,I?,S,S>((p0,p1,p2,p3) => Sql.Left(p0, p1 - 1) + p3 + Sql.Right(p0, p0.Length - (p1 + p2 - 1))) },
189
190 #endregion
191
192 #region Binary
193
194 { M(() => ((Binary)null).Length ), L<Binary,I>(obj => Sql.Length(obj).Value) },
195
196 #endregion
197
198 #region DateTime
199
200 { M(() => Sql.GetDate() ), L<D> (() => Sql.CurrentTimestamp2 ) },
201 { M(() => DateTime.Now ), L<D> (() => Sql.CurrentTimestamp2 ) },
202
203 { M(() => DateTime.Now.Year ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.Year, obj).Value ) },
204 { M(() => DateTime.Now.Month ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.Month, obj).Value ) },
205 { M(() => DateTime.Now.DayOfYear ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.DayOfYear, obj).Value ) },
206 { M(() => DateTime.Now.Day ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.Day, obj).Value ) },
207 { M(() => DateTime.Now.DayOfWeek ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.WeekDay, obj).Value - 1 ) },
208 { M(() => DateTime.Now.Hour ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.Hour, obj).Value ) },
209 { M(() => DateTime.Now.Minute ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.Minute, obj).Value ) },
210 { M(() => DateTime.Now.Second ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.Second, obj).Value ) },
211 { M(() => DateTime.Now.Millisecond ), L<D,I> (obj => Sql.DatePart(Sql.DateParts.Millisecond, obj).Value ) },
212 { M(() => DateTime.Now.Date ), L<D,D> (obj => Sql.Convert2(Sql.Date, obj) ) },
213 { M(() => DateTime.Now.TimeOfDay ), L<D,T> (obj => Sql.DateToTime(Sql.Convert2(Sql.Time, obj)).Value ) },
214 { M(() => DateTime.Now.AddYears (0)), L<D,I,D> ((obj,p0) => Sql.DateAdd(Sql.DateParts.Year, p0, obj).Value ) },
215 { M(() => DateTime.Now.AddMonths (0)), L<D,I,D> ((obj,p0) => Sql.DateAdd(Sql.DateParts.Month, p0, obj).Value ) },
216 { M(() => DateTime.Now.AddDays (0)), L<D,F,D> ((obj,p0) => Sql.DateAdd(Sql.DateParts.Day, p0, obj).Value ) },
217 { M(() => DateTime.Now.AddHours (0)), L<D,F,D> ((obj,p0) => Sql.DateAdd(Sql.DateParts.Hour, p0, obj).Value ) },
218 { M(() => DateTime.Now.AddMinutes (0)), L<D,F,D> ((obj,p0) => Sql.DateAdd(Sql.DateParts.Minute, p0, obj).Value ) },
219 { M(() => DateTime.Now.AddSeconds (0)), L<D,F,D> ((obj,p0) => Sql.DateAdd(Sql.DateParts.Second, p0, obj).Value ) },
220 { M(() => DateTime.Now.AddMilliseconds(0)), L<D,F,D> ((obj,p0) => Sql.DateAdd(Sql.DateParts.Millisecond, p0, obj).Value ) },
221 { M(() => new DateTime(0, 0, 0) ), L<I,I,I,D>((y,m,d) => Sql.MakeDateTime(y, m, d).Value ) },
222
223 { M(() => Sql.MakeDateTime(0, 0, 0) ), L<I?,I?,I?,D?> ((y,m,d) => Sql.Convert(Sql.Date, y.ToString() + "-" + m.ToString() + "-" + d.ToString())) },
224 { M(() => new DateTime (0, 0, 0, 0, 0, 0) ), L<I,I,I,I,I,I,D> ((y,m,d,h,mm,s) => Sql.MakeDateTime(y, m, d, h, mm, s).Value ) },
225 { M(() => Sql.MakeDateTime(0, 0, 0, 0, 0, 0) ), L<I?,I?,I?,I?,I?,I?,D?>((y,m,d,h,mm,s) => Sql.Convert(Sql.DateTime2,
226 y.ToString() + "-" + m.ToString() + "-" + d.ToString() + " " +
227 h.ToString() + ":" + mm.ToString() + ":" + s.ToString())) },
228
229 #endregion
230
231 #region Parse
232
233 { M(() => Boolean. Parse("")), L<String,Boolean> (p0 => Sql.ConvertTo<Boolean>. From(p0) ) },
234 { M(() => Byte. Parse("")), L<String,Byte> (p0 => Sql.ConvertTo<Byte>. From(p0) ) },
235 #if !SILVERLIGHT
236 { M(() => Char. Parse("")), L<String,Char> (p0 => Sql.ConvertTo<Char>. From(p0) ) },
237 #endif
238 { M(() => DateTime.Parse("")), L<String,DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
239 { M(() => Decimal. Parse("")), L<String,Decimal> (p0 => Sql.ConvertTo<Decimal>. From(p0) ) },
240 { M(() => Double. Parse("")), L<String,Double> (p0 => Sql.ConvertTo<Double>. From(p0) ) },
241 { M(() => Int16. Parse("")), L<String,Int16> (p0 => Sql.ConvertTo<Int16>. From(p0) ) },
242 { M(() => Int32. Parse("")), L<String,Int32> (p0 => Sql.ConvertTo<Int32>. From(p0) ) },
243 { M(() => Int64. Parse("")), L<String,Int64> (p0 => Sql.ConvertTo<Int64>. From(p0) ) },
244 { M(() => SByte. Parse("")), L<String,SByte> (p0 => Sql.ConvertTo<SByte>. From(p0) ) },
245 { M(() => Single. Parse("")), L<String,Single> (p0 => Sql.ConvertTo<Single>. From(p0) ) },
246 { M(() => UInt16. Parse("")), L<String,UInt16> (p0 => Sql.ConvertTo<UInt16>. From(p0) ) },
247 { M(() => UInt32. Parse("")), L<String,UInt32> (p0 => Sql.ConvertTo<UInt32>. From(p0) ) },
248 { M(() => UInt64. Parse("")), L<String,UInt64> (p0 => Sql.ConvertTo<UInt64>. From(p0) ) },
249
250 #endregion
251
252 #region ToString
253
254 { M(() => ((Boolean)true).ToString()), L<Boolean, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
255 { M(() => ((Byte) 0) .ToString()), L<Byte, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
256 { M(() => ((Char) '0') .ToString()), L<Char, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
257 { M(() => ((Decimal) 0) .ToString()), L<Decimal, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
258 { M(() => ((Double) 0) .ToString()), L<Double, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
259 { M(() => ((Int16) 0) .ToString()), L<Int16, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
260 { M(() => ((Int32) 0) .ToString()), L<Int32, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
261 { M(() => ((Int64) 0) .ToString()), L<Int64, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
262 { M(() => ((SByte) 0) .ToString()), L<SByte, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
263 { M(() => ((Single) 0) .ToString()), L<Single, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
264 { M(() => ((String) "0") .ToString()), L<String, String>(p0 => p0 ) },
265 { M(() => ((UInt16) 0) .ToString()), L<UInt16, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
266 { M(() => ((UInt32) 0) .ToString()), L<UInt32, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
267 { M(() => ((UInt64) 0) .ToString()), L<UInt64, String>(p0 => Sql.ConvertTo<string>.From(p0) ) },
268
269 #endregion
270
271 #region Convert
272
273 #region ToBoolean
274
275 { M(() => Convert.ToBoolean((Boolean)true)), L<Boolean, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
276 { M(() => Convert.ToBoolean((Byte) 0) ), L<Byte, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
277 { M(() => Convert.ToBoolean((Char) '0') ), L<Char, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
278 #if !SILVERLIGHT
279 { M(() => Convert.ToBoolean(DateTime.Now) ), L<DateTime,Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
280 #endif
281 { M(() => Convert.ToBoolean((Decimal) 0) ), L<Decimal, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
282 { M(() => Convert.ToBoolean((Double) 0) ), L<Double, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
283 { M(() => Convert.ToBoolean((Int16) 0) ), L<Int16, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
284 { M(() => Convert.ToBoolean((Int32) 0) ), L<Int32, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
285 { M(() => Convert.ToBoolean((Int64) 0) ), L<Int64, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
286 { M(() => Convert.ToBoolean((Object) 0) ), L<Object, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
287 { M(() => Convert.ToBoolean((SByte) 0) ), L<SByte, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
288 { M(() => Convert.ToBoolean((Single) 0) ), L<Single, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
289 { M(() => Convert.ToBoolean((String) "0") ), L<String, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
290 { M(() => Convert.ToBoolean((UInt16) 0) ), L<UInt16, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
291 { M(() => Convert.ToBoolean((UInt32) 0) ), L<UInt32, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
292 { M(() => Convert.ToBoolean((UInt64) 0) ), L<UInt64, Boolean>(p0 => Sql.ConvertTo<Boolean>.From(p0) ) },
293
294 #endregion
295
296 #region ToByte
297
298 { M(() => Convert.ToByte((Boolean)true)), L<Boolean, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
299 { M(() => Convert.ToByte((Byte) 0) ), L<Byte, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
300 { M(() => Convert.ToByte((Char) '0') ), L<Char, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
301 #if !SILVERLIGHT
302 { M(() => Convert.ToByte(DateTime.Now) ), L<DateTime,Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
303 #endif
304 { M(() => Convert.ToByte((Decimal) 0) ), L<Decimal, Byte>(p0 => Sql.ConvertTo<Byte>.From(Sql.RoundToEven(p0)) ) },
305 { M(() => Convert.ToByte((Double) 0) ), L<Double, Byte>(p0 => Sql.ConvertTo<Byte>.From(Sql.RoundToEven(p0)) ) },
306 { M(() => Convert.ToByte((Int16) 0) ), L<Int16, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
307 { M(() => Convert.ToByte((Int32) 0) ), L<Int32, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
308 { M(() => Convert.ToByte((Int64) 0) ), L<Int64, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
309 { M(() => Convert.ToByte((Object) 0) ), L<Object, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
310 { M(() => Convert.ToByte((SByte) 0) ), L<SByte, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
311 { M(() => Convert.ToByte((Single) 0) ), L<Single, Byte>(p0 => Sql.ConvertTo<Byte>.From(Sql.RoundToEven(p0)) ) },
312 { M(() => Convert.ToByte((String) "0") ), L<String, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
313 { M(() => Convert.ToByte((UInt16) 0) ), L<UInt16, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
314 { M(() => Convert.ToByte((UInt32) 0) ), L<UInt32, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
315 { M(() => Convert.ToByte((UInt64) 0) ), L<UInt64, Byte>(p0 => Sql.ConvertTo<Byte>.From(p0) ) },
316
317 #endregion
318
319 #region ToChar
320
321 #if !SILVERLIGHT
322 { M(() => Convert.ToChar((Boolean)true)), L<Boolean, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
323 #endif
324 { M(() => Convert.ToChar((Byte) 0) ), L<Byte, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
325 { M(() => Convert.ToChar((Char) '0') ), L<Char, Char>(p0 => p0 ) },
326 #if !SILVERLIGHT
327 { M(() => Convert.ToChar(DateTime.Now) ), L<DateTime,Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
328 #endif
329 { M(() => Convert.ToChar((Decimal) 0) ), L<Decimal, Char>(p0 => Sql.ConvertTo<Char>.From(Sql.RoundToEven(p0)) ) },
330 { M(() => Convert.ToChar((Double) 0) ), L<Double, Char>(p0 => Sql.ConvertTo<Char>.From(Sql.RoundToEven(p0)) ) },
331 { M(() => Convert.ToChar((Int16) 0) ), L<Int16, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
332 { M(() => Convert.ToChar((Int32) 0) ), L<Int32, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
333 { M(() => Convert.ToChar((Int64) 0) ), L<Int64, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
334 { M(() => Convert.ToChar((Object) 0) ), L<Object, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
335 { M(() => Convert.ToChar((SByte) 0) ), L<SByte, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
336 { M(() => Convert.ToChar((Single) 0) ), L<Single, Char>(p0 => Sql.ConvertTo<Char>.From(Sql.RoundToEven(p0)) ) },
337 { M(() => Convert.ToChar((String) "0") ), L<String, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
338 { M(() => Convert.ToChar((UInt16) 0) ), L<UInt16, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
339 { M(() => Convert.ToChar((UInt32) 0) ), L<UInt32, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
340 { M(() => Convert.ToChar((UInt64) 0) ), L<UInt64, Char>(p0 => Sql.ConvertTo<Char>.From(p0) ) },
341
342 #endregion
343
344 #region ToDateTime
345
346 { M(() => Convert.ToDateTime((Object) 0) ), L<Object, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
347 { M(() => Convert.ToDateTime((String) "0") ), L<String, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
348 #if !SILVERLIGHT
349 { M(() => Convert.ToDateTime((Boolean)true)), L<Boolean, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
350 { M(() => Convert.ToDateTime((Byte) 0) ), L<Byte, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
351 { M(() => Convert.ToDateTime((Char) '0') ), L<Char, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
352 { M(() => Convert.ToDateTime(DateTime.Now) ), L<DateTime,DateTime>(p0 => p0 ) },
353 { M(() => Convert.ToDateTime((Decimal) 0) ), L<Decimal, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
354 { M(() => Convert.ToDateTime((Double) 0) ), L<Double, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
355 { M(() => Convert.ToDateTime((Int16) 0) ), L<Int16, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
356 { M(() => Convert.ToDateTime((Int32) 0) ), L<Int32, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
357 { M(() => Convert.ToDateTime((Int64) 0) ), L<Int64, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
358 { M(() => Convert.ToDateTime((SByte) 0) ), L<SByte, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
359 { M(() => Convert.ToDateTime((Single) 0) ), L<Single, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
360 { M(() => Convert.ToDateTime((UInt16) 0) ), L<UInt16, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
361 { M(() => Convert.ToDateTime((UInt32) 0) ), L<UInt32, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
362 { M(() => Convert.ToDateTime((UInt64) 0) ), L<UInt64, DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
363 #endif
364
365 #endregion
366
367 #region ToDecimal
368
369 { M(() => Convert.ToDecimal((Boolean)true)), L<Boolean, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
370 { M(() => Convert.ToDecimal((Byte) 0) ), L<Byte, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
371 { M(() => Convert.ToDecimal((Char) '0') ), L<Char, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
372 { M(() => Convert.ToDecimal(DateTime.Now) ), L<DateTime,Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
373 { M(() => Convert.ToDecimal((Decimal) 0) ), L<Decimal, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
374 { M(() => Convert.ToDecimal((Double) 0) ), L<Double, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
375 { M(() => Convert.ToDecimal((Int16) 0) ), L<Int16, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
376 { M(() => Convert.ToDecimal((Int32) 0) ), L<Int32, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
377 { M(() => Convert.ToDecimal((Int64) 0) ), L<Int64, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
378 { M(() => Convert.ToDecimal((Object) 0) ), L<Object, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
379 { M(() => Convert.ToDecimal((SByte) 0) ), L<SByte, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
380 { M(() => Convert.ToDecimal((Single) 0) ), L<Single, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
381 { M(() => Convert.ToDecimal((String) "0") ), L<String, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
382 { M(() => Convert.ToDecimal((UInt16) 0) ), L<UInt16, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
383 { M(() => Convert.ToDecimal((UInt32) 0) ), L<UInt32, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
384 { M(() => Convert.ToDecimal((UInt64) 0) ), L<UInt64, Decimal>(p0 => Sql.ConvertTo<Decimal>.From(p0) ) },
385
386 #endregion
387
388 #region ToDouble
389
390 { M(() => Convert.ToDouble((Boolean)true)), L<Boolean, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
391 { M(() => Convert.ToDouble((Byte) 0) ), L<Byte, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
392 { M(() => Convert.ToDouble((Char) '0') ), L<Char, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
393 #if !SILVERLIGHT
394 { M(() => Convert.ToDouble(DateTime.Now) ), L<DateTime,Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
395 #endif
396 { M(() => Convert.ToDouble((Decimal) 0) ), L<Decimal, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
397 { M(() => Convert.ToDouble((Double) 0) ), L<Double, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
398 { M(() => Convert.ToDouble((Int16) 0) ), L<Int16, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
399 { M(() => Convert.ToDouble((Int32) 0) ), L<Int32, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
400 { M(() => Convert.ToDouble((Int64) 0) ), L<Int64, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
401 { M(() => Convert.ToDouble((Object) 0) ), L<Object, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
402 { M(() => Convert.ToDouble((SByte) 0) ), L<SByte, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
403 { M(() => Convert.ToDouble((Single) 0) ), L<Single, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
404 { M(() => Convert.ToDouble((String) "0") ), L<String, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
405 { M(() => Convert.ToDouble((UInt16) 0) ), L<UInt16, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
406 { M(() => Convert.ToDouble((UInt32) 0) ), L<UInt32, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
407 { M(() => Convert.ToDouble((UInt64) 0) ), L<UInt64, Double>(p0 => Sql.ConvertTo<Double>.From(p0) ) },
408
409 #endregion
410
411 #region ToInt64
412
413 { M(() => Convert.ToInt64((Boolean)true)), L<Boolean, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
414 { M(() => Convert.ToInt64((Byte) 0) ), L<Byte, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
415 { M(() => Convert.ToInt64((Char) '0') ), L<Char, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
416 #if !SILVERLIGHT
417 { M(() => Convert.ToInt64(DateTime.Now) ), L<DateTime,Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
418 #endif
419 { M(() => Convert.ToInt64((Decimal) 0) ), L<Decimal, Int64>(p0 => Sql.ConvertTo<Int64>.From(Sql.RoundToEven(p0)) ) },
420 { M(() => Convert.ToInt64((Double) 0) ), L<Double, Int64>(p0 => Sql.ConvertTo<Int64>.From(Sql.RoundToEven(p0)) ) },
421 { M(() => Convert.ToInt64((Int16) 0) ), L<Int16, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
422 { M(() => Convert.ToInt64((Int32) 0) ), L<Int32, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
423 { M(() => Convert.ToInt64((Int64) 0) ), L<Int64, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
424 { M(() => Convert.ToInt64((Object) 0) ), L<Object, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
425 { M(() => Convert.ToInt64((SByte) 0) ), L<SByte, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
426 { M(() => Convert.ToInt64((Single) 0) ), L<Single, Int64>(p0 => Sql.ConvertTo<Int64>.From(Sql.RoundToEven(p0)) ) },
427 { M(() => Convert.ToInt64((String) "0") ), L<String, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
428 { M(() => Convert.ToInt64((UInt16) 0) ), L<UInt16, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
429 { M(() => Convert.ToInt64((UInt32) 0) ), L<UInt32, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
430 { M(() => Convert.ToInt64((UInt64) 0) ), L<UInt64, Int64>(p0 => Sql.ConvertTo<Int64>.From(p0) ) },
431
432 #endregion
433
434 #region ToInt32
435
436 { M(() => Convert.ToInt32((Boolean)true)), L<Boolean, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
437 { M(() => Convert.ToInt32((Byte) 0) ), L<Byte, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
438 { M(() => Convert.ToInt32((Char) '0') ), L<Char, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
439 #if !SILVERLIGHT
440 { M(() => Convert.ToInt32(DateTime.Now) ), L<DateTime,Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
441 #endif
442 { M(() => Convert.ToInt32((Decimal) 0) ), L<Decimal, Int32>(p0 => Sql.ConvertTo<Int32>.From(Sql.RoundToEven(p0)) ) },
443 { M(() => Convert.ToInt32((Double) 0) ), L<Double, Int32>(p0 => Sql.ConvertTo<Int32>.From(Sql.RoundToEven(p0)) ) },
444 { M(() => Convert.ToInt32((Int16) 0) ), L<Int16, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
445 { M(() => Convert.ToInt32((Int32) 0) ), L<Int32, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
446 { M(() => Convert.ToInt32((Int64) 0) ), L<Int64, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
447 { M(() => Convert.ToInt32((Object) 0) ), L<Object, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
448 { M(() => Convert.ToInt32((SByte) 0) ), L<SByte, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
449 { M(() => Convert.ToInt32((Single) 0) ), L<Single, Int32>(p0 => Sql.ConvertTo<Int32>.From(Sql.RoundToEven(p0)) ) },
450 { M(() => Convert.ToInt32((String) "0") ), L<String, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
451 { M(() => Convert.ToInt32((UInt16) 0) ), L<UInt16, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
452 { M(() => Convert.ToInt32((UInt32) 0) ), L<UInt32, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
453 { M(() => Convert.ToInt32((UInt64) 0) ), L<UInt64, Int32>(p0 => Sql.ConvertTo<Int32>.From(p0) ) },
454
455 #endregion
456
457 #region ToInt16
458
459 { M(() => Convert.ToInt16((Boolean)true)), L<Boolean, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
460 { M(() => Convert.ToInt16((Byte) 0) ), L<Byte, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
461 { M(() => Convert.ToInt16((Char) '0') ), L<Char, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
462 #if !SILVERLIGHT
463 { M(() => Convert.ToInt16(DateTime.Now) ), L<DateTime,Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
464 #endif
465 { M(() => Convert.ToInt16((Decimal) 0) ), L<Decimal, Int16>(p0 => Sql.ConvertTo<Int16>.From(Sql.RoundToEven(p0)) ) },
466 { M(() => Convert.ToInt16((Double) 0) ), L<Double, Int16>(p0 => Sql.ConvertTo<Int16>.From(Sql.RoundToEven(p0)) ) },
467 { M(() => Convert.ToInt16((Int16) 0) ), L<Int16, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
468 { M(() => Convert.ToInt16((Int32) 0) ), L<Int32, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
469 { M(() => Convert.ToInt16((Int64) 0) ), L<Int64, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
470 { M(() => Convert.ToInt16((Object) 0) ), L<Object, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
471 { M(() => Convert.ToInt16((SByte) 0) ), L<SByte, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
472 { M(() => Convert.ToInt16((Single) 0) ), L<Single, Int16>(p0 => Sql.ConvertTo<Int16>.From(Sql.RoundToEven(p0)) ) },
473 { M(() => Convert.ToInt16((String) "0") ), L<String, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
474 { M(() => Convert.ToInt16((UInt16) 0) ), L<UInt16, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
475 { M(() => Convert.ToInt16((UInt32) 0) ), L<UInt32, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
476 { M(() => Convert.ToInt16((UInt64) 0) ), L<UInt64, Int16>(p0 => Sql.ConvertTo<Int16>.From(p0) ) },
477
478 #endregion
479
480 #region ToSByte
481
482 { M(() => Convert.ToSByte((Boolean)true)), L<Boolean, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
483 { M(() => Convert.ToSByte((Byte) 0) ), L<Byte, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
484 { M(() => Convert.ToSByte((Char) '0') ), L<Char, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
485 #if !SILVERLIGHT
486 { M(() => Convert.ToSByte(DateTime.Now) ), L<DateTime,SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
487 #endif
488 { M(() => Convert.ToSByte((Decimal) 0) ), L<Decimal, SByte>(p0 => Sql.ConvertTo<SByte>.From(Sql.RoundToEven(p0)) ) },
489 { M(() => Convert.ToSByte((Double) 0) ), L<Double, SByte>(p0 => Sql.ConvertTo<SByte>.From(Sql.RoundToEven(p0)) ) },
490 { M(() => Convert.ToSByte((Int16) 0) ), L<Int16, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
491 { M(() => Convert.ToSByte((Int32) 0) ), L<Int32, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
492 { M(() => Convert.ToSByte((Int64) 0) ), L<Int64, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
493 { M(() => Convert.ToSByte((Object) 0) ), L<Object, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
494 { M(() => Convert.ToSByte((SByte) 0) ), L<SByte, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
495 { M(() => Convert.ToSByte((Single) 0) ), L<Single, SByte>(p0 => Sql.ConvertTo<SByte>.From(Sql.RoundToEven(p0)) ) },
496 { M(() => Convert.ToSByte((String) "0") ), L<String, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
497 { M(() => Convert.ToSByte((UInt16) 0) ), L<UInt16, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
498 { M(() => Convert.ToSByte((UInt32) 0) ), L<UInt32, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
499 { M(() => Convert.ToSByte((UInt64) 0) ), L<UInt64, SByte>(p0 => Sql.ConvertTo<SByte>.From(p0) ) },
500
501 #endregion
502
503 #region ToSingle
504
505 { M(() => Convert.ToSingle((Boolean)true)), L<Boolean, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
506 { M(() => Convert.ToSingle((Byte) 0) ), L<Byte, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
507 { M(() => Convert.ToSingle((Char) '0') ), L<Char, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
508 #if !SILVERLIGHT
509 { M(() => Convert.ToSingle(DateTime.Now) ), L<DateTime,Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
510 #endif
511 { M(() => Convert.ToSingle((Decimal) 0) ), L<Decimal, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
512 { M(() => Convert.ToSingle((Double) 0) ), L<Double, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
513 { M(() => Convert.ToSingle((Int16) 0) ), L<Int16, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
514 { M(() => Convert.ToSingle((Int32) 0) ), L<Int32, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
515 { M(() => Convert.ToSingle((Int64) 0) ), L<Int64, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
516 { M(() => Convert.ToSingle((Object) 0) ), L<Object, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
517 { M(() => Convert.ToSingle((SByte) 0) ), L<SByte, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
518 { M(() => Convert.ToSingle((Single) 0) ), L<Single, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
519 { M(() => Convert.ToSingle((String) "0") ), L<String, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
520 { M(() => Convert.ToSingle((UInt16) 0) ), L<UInt16, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
521 { M(() => Convert.ToSingle((UInt32) 0) ), L<UInt32, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
522 { M(() => Convert.ToSingle((UInt64) 0) ), L<UInt64, Single>(p0 => Sql.ConvertTo<Single>.From(p0) ) },
523
524 #endregion
525
526 #region ToString
527
528 { M(() => Convert.ToString((Boolean)true)), L<Boolean, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
529 { M(() => Convert.ToString((Byte) 0) ), L<Byte, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
530 { M(() => Convert.ToString((Char) '0') ), L<Char, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
531 { M(() => Convert.ToString(DateTime.Now) ), L<DateTime,String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
532 { M(() => Convert.ToString((Decimal) 0) ), L<Decimal, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
533 { M(() => Convert.ToString((Double) 0) ), L<Double, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
534 { M(() => Convert.ToString((Int16) 0) ), L<Int16, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
535 { M(() => Convert.ToString((Int32) 0) ), L<Int32, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
536 { M(() => Convert.ToString((Int64) 0) ), L<Int64, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
537 { M(() => Convert.ToString((Object) 0) ), L<Object, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
538 { M(() => Convert.ToString((SByte) 0) ), L<SByte, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
539 { M(() => Convert.ToString((Single) 0) ), L<Single, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
540 #if !SILVERLIGHT
541 { M(() => Convert.ToString((String) "0") ), L<String, String>(p0 => p0 ) },
542 #endif
543 { M(() => Convert.ToString((UInt16) 0) ), L<UInt16, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
544 { M(() => Convert.ToString((UInt32) 0) ), L<UInt32, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
545 { M(() => Convert.ToString((UInt64) 0) ), L<UInt64, String>(p0 => Sql.ConvertTo<String>.From(p0) ) },
546
547 #endregion
548
549 #region ToInt16
550
551 { M(() => Convert.ToUInt16((Boolean)true)), L<Boolean, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
552 { M(() => Convert.ToUInt16((Byte) 0) ), L<Byte, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
553 { M(() => Convert.ToUInt16((Char) '0') ), L<Char, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
554 #if !SILVERLIGHT
555 { M(() => Convert.ToUInt16(DateTime.Now) ), L<DateTime,UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
556 #endif
557 { M(() => Convert.ToUInt16((Decimal) 0) ), L<Decimal, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(Sql.RoundToEven(p0)) ) },
558 { M(() => Convert.ToUInt16((Double) 0) ), L<Double, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(Sql.RoundToEven(p0)) ) },
559 { M(() => Convert.ToUInt16((Int16) 0) ), L<Int16, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
560 { M(() => Convert.ToUInt16((Int32) 0) ), L<Int32, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
561 { M(() => Convert.ToUInt16((Int64) 0) ), L<Int64, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
562 { M(() => Convert.ToUInt16((Object) 0) ), L<Object, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
563 { M(() => Convert.ToUInt16((SByte) 0) ), L<SByte, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
564 { M(() => Convert.ToUInt16((Single) 0) ), L<Single, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(Sql.RoundToEven(p0)) ) },
565 { M(() => Convert.ToUInt16((String) "0") ), L<String, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
566 { M(() => Convert.ToUInt16((UInt16) 0) ), L<UInt16, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
567 { M(() => Convert.ToUInt16((UInt32) 0) ), L<UInt32, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
568 { M(() => Convert.ToUInt16((UInt64) 0) ), L<UInt64, UInt16>(p0 => Sql.ConvertTo<UInt16>.From(p0) ) },
569
570 #endregion
571
572 #region ToInt32
573
574 { M(() => Convert.ToUInt32((Boolean)true)), L<Boolean, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
575 { M(() => Convert.ToUInt32((Byte) 0) ), L<Byte, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
576 { M(() => Convert.ToUInt32((Char) '0') ), L<Char, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
577 #if !SILVERLIGHT
578 { M(() => Convert.ToUInt32(DateTime.Now) ), L<DateTime,UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
579 #endif
580 { M(() => Convert.ToUInt32((Decimal) 0) ), L<Decimal, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(Sql.RoundToEven(p0)) ) },
581 { M(() => Convert.ToUInt32((Double) 0) ), L<Double, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(Sql.RoundToEven(p0)) ) },
582 { M(() => Convert.ToUInt32((Int16) 0) ), L<Int16, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
583 { M(() => Convert.ToUInt32((Int32) 0) ), L<Int32, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
584 { M(() => Convert.ToUInt32((Int64) 0) ), L<Int64, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
585 { M(() => Convert.ToUInt32((Object) 0) ), L<Object, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
586 { M(() => Convert.ToUInt32((SByte) 0) ), L<SByte, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
587 { M(() => Convert.ToUInt32((Single) 0) ), L<Single, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(Sql.RoundToEven(p0)) ) },
588 { M(() => Convert.ToUInt32((String) "0") ), L<String, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
589 { M(() => Convert.ToUInt32((UInt16) 0) ), L<UInt16, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
590 { M(() => Convert.ToUInt32((UInt32) 0) ), L<UInt32, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
591 { M(() => Convert.ToUInt32((UInt64) 0) ), L<UInt64, UInt32>(p0 => Sql.ConvertTo<UInt32>.From(p0) ) },
592
593 #endregion
594
595 #region ToUInt64
596
597 { M(() => Convert.ToUInt64((Boolean)true)), L<Boolean, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
598 { M(() => Convert.ToUInt64((Byte) 0) ), L<Byte, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
599 { M(() => Convert.ToUInt64((Char) '0') ), L<Char, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
600 #if !SILVERLIGHT
601 { M(() => Convert.ToUInt64(DateTime.Now) ), L<DateTime,UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
602 #endif
603 { M(() => Convert.ToUInt64((Decimal) 0) ), L<Decimal, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(Sql.RoundToEven(p0)) ) },
604 { M(() => Convert.ToUInt64((Double) 0) ), L<Double, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(Sql.RoundToEven(p0)) ) },
605 { M(() => Convert.ToUInt64((Int16) 0) ), L<Int16, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
606 { M(() => Convert.ToUInt64((Int32) 0) ), L<Int32, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
607 { M(() => Convert.ToUInt64((Int64) 0) ), L<Int64, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
608 { M(() => Convert.ToUInt64((Object) 0) ), L<Object, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
609 { M(() => Convert.ToUInt64((SByte) 0) ), L<SByte, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
610 { M(() => Convert.ToUInt64((Single) 0) ), L<Single, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(Sql.RoundToEven(p0)) ) },
611 { M(() => Convert.ToUInt64((String) "0") ), L<String, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
612 { M(() => Convert.ToUInt64((UInt16) 0) ), L<UInt16, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
613 { M(() => Convert.ToUInt64((UInt32) 0) ), L<UInt32, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
614 { M(() => Convert.ToUInt64((UInt64) 0) ), L<UInt64, UInt64>(p0 => Sql.ConvertTo<UInt64>.From(p0) ) },
615
616 #endregion
617
618 #endregion
619
620 #region Math
621
622 { M(() => Math.Abs ((Decimal)0)), L<Decimal,Decimal>(p => Sql.Abs(p).Value ) },
623 { M(() => Math.Abs ((Double) 0)), L<Double, Double> (p => Sql.Abs(p).Value ) },
624 { M(() => Math.Abs ((Int16) 0)), L<Int16, Int16> (p => Sql.Abs(p).Value ) },
625 { M(() => Math.Abs ((Int32) 0)), L<Int32, Int32> (p => Sql.Abs(p).Value ) },
626 { M(() => Math.Abs ((Int64) 0)), L<Int64, Int64> (p => Sql.Abs(p).Value ) },
627 { M(() => Math.Abs ((SByte) 0)), L<SByte, SByte> (p => Sql.Abs(p).Value ) },
628 { M(() => Math.Abs ((Single) 0)), L<Single, Single> (p => Sql.Abs(p).Value ) },
629
630 { M(() => Math.Acos (0) ), L<F,F> ( p => Sql.Acos (p) .Value ) },
631 { M(() => Math.Asin (0) ), L<F,F> ( p => Sql.Asin (p) .Value ) },
632 { M(() => Math.Atan (0) ), L<F,F> ( p => Sql.Atan (p) .Value ) },
633 { M(() => Math.Atan2 (0,0) ), L<F,F,F>((x,y) => Sql.Atan2 (x, y).Value ) },
634 #if !SILVERLIGHT
635 { M(() => Math.Ceiling((M)0)), L<M,M> ( p => Sql.Ceiling(p) .Value ) },
636 #endif
637 { M(() => Math.Ceiling((F)0)), L<F,F> ( p => Sql.Ceiling(p) .Value ) },
638 { M(() => Math.Cos (0) ), L<F,F> ( p => Sql.Cos (p) .Value ) },
639 { M(() => Math.Cosh (0) ), L<F,F> ( p => Sql.Cosh (p) .Value ) },
640 { M(() => Math.Exp (0) ), L<F,F> ( p => Sql.Exp (p) .Value ) },
641 #if !SILVERLIGHT
642 { M(() => Math.Floor ((M)0)), L<M,M> ( p => Sql.Floor (p) .Value ) },
643 #endif
644 { M(() => Math.Floor ((F)0)), L<F,F> ( p => Sql.Floor (p) .Value ) },
645 { M(() => Math.Log (0) ), L<F,F> ( p => Sql.Log (p) .Value ) },
646 { M(() => Math.Log (0,0) ), L<F,F,F>((m,n) => Sql.Log (n, m).Value ) },
647 { M(() => Math.Log10 (0) ), L<F,F> ( p => Sql.Log10 (p) .Value ) },
648
649 { M(() => Math.Max((Byte) 0, (Byte) 0)), L<Byte, Byte, Byte> ((v1,v2) => v1 > v2 ? v1 : v2) },
650 { M(() => Math.Max((Decimal)0, (Decimal)0)), L<Decimal,Decimal,Decimal>((v1,v2) => v1 > v2 ? v1 : v2) },
651 { M(() => Math.Max((Double) 0, (Double) 0)), L<Double, Double, Double> ((v1,v2) => v1 > v2 ? v1 : v2) },
652 { M(() => Math.Max((Int16) 0, (Int16) 0)), L<Int16, Int16, Int16> ((v1,v2) => v1 > v2 ? v1 : v2) },
653 { M(() => Math.Max((Int32) 0, (Int32) 0)), L<Int32, Int32, Int32> ((v1,v2) => v1 > v2 ? v1 : v2) },
654 { M(() => Math.Max((Int64) 0, (Int64) 0)), L<Int64, Int64, Int64> ((v1,v2) => v1 > v2 ? v1 : v2) },
655 { M(() => Math.Max((SByte) 0, (SByte) 0)), L<SByte, SByte, SByte> ((v1,v2) => v1 > v2 ? v1 : v2) },
656 { M(() => Math.Max((Single) 0, (Single) 0)), L<Single, Single, Single> ((v1,v2) => v1 > v2 ? v1 : v2) },
657 { M(() => Math.Max((UInt16) 0, (UInt16) 0)), L<UInt16, UInt16, UInt16> ((v1,v2) => v1 > v2 ? v1 : v2) },
658 { M(() => Math.Max((UInt32) 0, (UInt32) 0)), L<UInt32, UInt32, UInt32> ((v1,v2) => v1 > v2 ? v1 : v2) },
659 { M(() => Math.Max((UInt64) 0, (UInt64) 0)), L<UInt64, UInt64, UInt64> ((v1,v2) => v1 > v2 ? v1 : v2) },
660
661 { M(() => Math.Min((Byte) 0, (Byte) 0)), L<Byte, Byte, Byte> ((v1,v2) => v1 < v2 ? v1 : v2) },
662 { M(() => Math.Min((Decimal)0, (Decimal)0)), L<Decimal,Decimal,Decimal>((v1,v2) => v1 < v2 ? v1 : v2) },
663 { M(() => Math.Min((Double) 0, (Double) 0)), L<Double, Double, Double> ((v1,v2) => v1 < v2 ? v1 : v2) },
664 { M(() => Math.Min((Int16) 0, (Int16) 0)), L<Int16, Int16, Int16> ((v1,v2) => v1 < v2 ? v1 : v2) },
665 { M(() => Math.Min((Int32) 0, (Int32) 0)), L<Int32, Int32, Int32> ((v1,v2) => v1 < v2 ? v1 : v2) },
666 { M(() => Math.Min((Int64) 0, (Int64) 0)), L<Int64, Int64, Int64> ((v1,v2) => v1 < v2 ? v1 : v2) },
667 { M(() => Math.Min((SByte) 0, (SByte) 0)), L<SByte, SByte, SByte> ((v1,v2) => v1 < v2 ? v1 : v2) },
668 { M(() => Math.Min((Single) 0, (Single) 0)), L<Single, Single, Single> ((v1,v2) => v1 < v2 ? v1 : v2) },
669 { M(() => Math.Min((UInt16) 0, (UInt16) 0)), L<UInt16, UInt16, UInt16> ((v1,v2) => v1 < v2 ? v1 : v2) },
670 { M(() => Math.Min((UInt32) 0, (UInt32) 0)), L<UInt32, UInt32, UInt32> ((v1,v2) => v1 < v2 ? v1 : v2) },
671 { M(() => Math.Min((UInt64) 0, (UInt64) 0)), L<UInt64, UInt64, UInt64> ((v1,v2) => v1 < v2 ? v1 : v2) },
672
673 { M(() => Math.Pow (0,0)), L<F,F,F>((x,y) => Sql.Power(x, y).Value ) },
674
675 { M(() => Sql.Round (0m) ), L<M?,M?> ( d => Sql.Round(d, 0)) },
676 { M(() => Sql.Round (0.0) ), L<F?,F?> ( d => Sql.Round(d, 0)) },
677
678 { M(() => Sql.RoundToEven(0m) ), L<M?,M?> ( d => d - Sql.Floor(d) == 0.5m && Sql.Floor(d) % 2 == 0? Sql.Floor(d) : Sql.Round(d)) },
679 { M(() => Sql.RoundToEven(0.0) ), L<F?,F?> ( d => d - Sql.Floor(d) == 0.5 && Sql.Floor(d) % 2 == 0? Sql.Floor(d) : Sql.Round(d)) },
680
681 { M(() => Sql.RoundToEven(0m, 0)), L<M?,I?,M?>((d,n) => d * 2 == Sql.Round(d * 2, n) && d != Sql.Round(d, n) ? Sql.Round(d / 2, n) * 2 : Sql.Round(d, n)) },
682 { M(() => Sql.RoundToEven(0.0,0)), L<F?,I?,F?>((d,n) => d * 2 == Sql.Round(d * 2, n) && d != Sql.Round(d, n) ? Sql.Round(d / 2, n) * 2 : Sql.Round(d, n)) },
683
684 { M(() => Math.Round (0m) ), L<M,M> ( d => Sql.RoundToEven(d).Value ) },
685 { M(() => Math.Round (0.0) ), L<F,F> ( d => Sql.RoundToEven(d).Value ) },
686
687 { M(() => Math.Round (0m, 0)), L<M,I,M> ((d,n) => Sql.RoundToEven(d, n).Value ) },
688 { M(() => Math.Round (0.0,0)), L<F,I,F> ((d,n) => Sql.RoundToEven(d, n).Value ) },
689
690 #if !SILVERLIGHT
691 { M(() => Math.Round (0m, MidpointRounding.ToEven)), L<M, MidpointRounding,M>((d, p) => p == MidpointRounding.ToEven ? Sql.RoundToEven(d). Value : Sql.Round(d). Value ) },
692 { M(() => Math.Round (0.0, MidpointRounding.ToEven)), L<F, MidpointRounding,F>((d, p) => p == MidpointRounding.ToEven ? Sql.RoundToEven(d). Value : Sql.Round(d). Value ) },
693
694 { M(() => Math.Round (0m, 0, MidpointRounding.ToEven)), L<M,I,MidpointRounding,M>((d,n,p) => p == MidpointRounding.ToEven ? Sql.RoundToEven(d,n).Value : Sql.Round(d,n).Value ) },
695 { M(() => Math.Round (0.0,0, MidpointRounding.ToEven)), L<F,I,MidpointRounding,F>((d,n,p) => p == MidpointRounding.ToEven ? Sql.RoundToEven(d,n).Value : Sql.Round(d,n).Value ) },
696 #endif
697
698 { M(() => Math.Sign ((Decimal)0)), L<Decimal,I>(p => Sql.Sign(p).Value ) },
699 { M(() => Math.Sign ((Double) 0)), L<Double, I>(p => Sql.Sign(p).Value ) },
700 { M(() => Math.Sign ((Int16) 0)), L<Int16, I>(p => Sql.Sign(p).Value ) },
701 { M(() => Math.Sign ((Int32) 0)), L<Int32, I>(p => Sql.Sign(p).Value ) },
702 { M(() => Math.Sign ((Int64) 0)), L<Int64, I>(p => Sql.Sign(p).Value ) },
703 { M(() => Math.Sign ((SByte) 0)), L<SByte, I>(p => Sql.Sign(p).Value ) },
704 { M(() => Math.Sign ((Single) 0)), L<Single, I>(p => Sql.Sign(p).Value ) },
705
706 { M(() => Math.Sin (0)), L<F,F>( p => Sql.Sin (p).Value ) },
707 { M(() => Math.Sinh (0)), L<F,F>( p => Sql.Sinh(p).Value ) },
708 { M(() => Math.Sqrt (0)), L<F,F>( p => Sql.Sqrt(p).Value ) },
709 { M(() => Math.Tan (0)), L<F,F>( p => Sql.Tan (p).Value ) },
710 { M(() => Math.Tanh (0)), L<F,F>( p => Sql.Tanh(p).Value ) },
711
712 #if !SILVERLIGHT
713 { M(() => Math.Truncate(0m)), L<M,M>( p => Sql.Truncate(p).Value ) },
714 { M(() => Math.Truncate(0.0)), L<F,F>( p => Sql.Truncate(p).Value ) },
715 #endif
716
717 #endregion
718
719 #region Visual Basic Compiler Services
720
721 //#if !SILVERLIGHT
722 // { M(() => Operators.CompareString("","",false)), L<S,S,B,I>((s1,s2,b) => b ? string.CompareOrdinal(s1.ToUpper(), s2.ToUpper()) : string.CompareOrdinal(s1, s2)) },
723 //#endif
724
725 #endregion
726
727 }},
728
729 #region MsSql2012
730
731 { "MsSql2012", new Dictionary<MemberInfo,LambdaExpression> {
732 { M(() => Sql.PadRight("",0,' ')), L<S,I?,C,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + Replicate(p2, p1 - p0.Length)) },
733 { M(() => Sql.PadLeft ("",0,' ')), L<S,I?,C,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : Replicate(p2, p1 - p0.Length) + p0) },
734 { M(() => Sql.Trim ("") ), L<S,S> ( p0 => Sql.TrimLeft(Sql.TrimRight(p0))) },
735 { M(() => Sql.MakeDateTime(0,0,0)), L<I?,I?,I?,D?>((y,m,d) => DateAdd(Sql.DateParts.Month, (y.Value - 1900) * 12 + m.Value - 1, d.Value - 1)) },
736
737 { M(() => Sql.Cosh(0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2) },
738 { M(() => Sql.Log(0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
739 { M(() => Sql.Log(0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
740 { M(() => Sql.Sinh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
741 { M(() => Sql.Tanh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
742 }},
743
744 #endregion
745
746 #region MsSql2008
747
748 { "MsSql2008", new Dictionary<MemberInfo,LambdaExpression> {
749 { M(() => Sql.PadRight("",0,' ')), L<S,I?,C,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + Replicate(p2, p1 - p0.Length)) },
750 { M(() => Sql.PadLeft ("",0,' ')), L<S,I?,C,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : Replicate(p2, p1 - p0.Length) + p0) },
751 { M(() => Sql.Trim ("") ), L<S,S> ( p0 => Sql.TrimLeft(Sql.TrimRight(p0))) },
752 { M(() => Sql.MakeDateTime(0,0,0)), L<I?,I?,I?,D?>((y,m,d) => DateAdd(Sql.DateParts.Month, (y.Value - 1900) * 12 + m.Value - 1, d.Value - 1)) },
753
754 { M(() => Sql.Cosh(0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2) },
755 { M(() => Sql.Log(0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
756 { M(() => Sql.Log(0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
757 { M(() => Sql.Sinh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
758 { M(() => Sql.Tanh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
759 }},
760
761 #endregion
762
763 #region MsSql2000
764
765 { "MsSql2000", new Dictionary<MemberInfo,LambdaExpression> {
766 { M(() => Sql.PadRight("",0,' ')), L<S,I?,C,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + Replicate(p2, p1 - p0.Length)) },
767 { M(() => Sql.PadLeft ("",0,' ')), L<S,I?,C,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : Replicate(p2, p1 - p0.Length) + p0) },
768 { M(() => Sql.Trim ("") ), L<S,S> ( p0 => Sql.TrimLeft(Sql.TrimRight(p0))) },
769 { M(() => Sql.MakeDateTime(0,0,0)), L<I?,I?,I?,D?>((y,m,d) => DateAdd(Sql.DateParts.Month, (y.Value - 1900) * 12 + m.Value - 1, d.Value - 1)) },
770 { M(() => Sql.MakeDateTime(0, 0, 0, 0, 0, 0) ), L<I?,I?,I?,I?,I?,I?,D?>((y,m,d,h,mm,s) => Sql.Convert(Sql.DateTime2,
771 y.ToString() + "-" + m.ToString() + "-" + d.ToString() + " " +
772 h.ToString() + ":" + mm.ToString() + ":" + s.ToString(), 120)) },
773 { M(() => Sql.Cosh(0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2) },
774 { M(() => Sql.Log(0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
775 { M(() => Sql.Log(0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
776 { M(() => Sql.Sinh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
777 { M(() => Sql.Tanh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
778
779 { M(() => DateTime.Parse("")), L<String,DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
780 { M(() => Sql.RoundToEven(0m) ), L<M?,M?>(d => d - Sql.Floor(d) == 0.5m && (long)Sql.Floor(d) % 2 == 0? Sql.Floor(d) : Sql.Round(d)) },
781 { M(() => Sql.RoundToEven(0.0)), L<F?,F?>(d => d - Sql.Floor(d) == 0.5 && (long)Sql.Floor(d) % 2 == 0? Sql.Floor(d) : Sql.Round(d)) },
782
783 }},
784
785 #endregion
786
787 #region MsSql2005
788
789 { "MsSql2005", new Dictionary<MemberInfo,LambdaExpression> {
790 { M(() => Sql.PadRight("",0,' ')), L<S,I?,C,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + Replicate(p2, p1 - p0.Length)) },
791 { M(() => Sql.PadLeft ("",0,' ')), L<S,I?,C,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : Replicate(p2, p1 - p0.Length) + p0) },
792 { M(() => Sql.Trim ("") ), L<S,S> ( p0 => Sql.TrimLeft(Sql.TrimRight(p0))) },
793 { M(() => Sql.MakeDateTime(0,0,0)), L<I?,I?,I?,D?>((y,m,d) => DateAdd(Sql.DateParts.Month, (y.Value - 1900) * 12 + m.Value - 1, d.Value - 1)) },
794 { M(() => Sql.MakeDateTime(0, 0, 0, 0, 0, 0) ), L<I?,I?,I?,I?,I?,I?,D?>((y,m,d,h,mm,s) => Sql.Convert(Sql.DateTime2,
795 y.ToString() + "-" + m.ToString() + "-" + d.ToString() + " " +
796 h.ToString() + ":" + mm.ToString() + ":" + s.ToString(), 120)) },
797 { M(() => Sql.Cosh(0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2) },
798 { M(() => Sql.Log(0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
799 { M(() => Sql.Log(0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
800 { M(() => Sql.Sinh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
801 { M(() => Sql.Tanh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
802
803 { M(() => DateTime.Parse("")), L<String,DateTime>(p0 => Sql.ConvertTo<DateTime>.From(p0) ) },
804 }},
805
806 #endregion
807
808 #region SqlCe
809
810 { "SqlCe", new Dictionary<MemberInfo,LambdaExpression> {
811 { M(() => Sql.Left ("",0) ), L<S,I?,S> ((p0,p1) => Sql.Substring(p0, 1, p1)) },
812 { M(() => Sql.Right ("",0) ), L<S,I?,S> ((p0,p1) => Sql.Substring(p0, p0.Length - p1 + 1, p1)) },
813 { M(() => Sql.PadRight("",0,' ')), L<S,I?,C?,S>((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + Replicate(p2, p1 - p0.Length)) },
814 { M(() => Sql.PadLeft ("",0,' ')), L<S,I?,C?,S>((p0,p1,p2) => p0.Length > p1 ? p0 : Replicate(p2, p1 - p0.Length) + p0) },
815 { M(() => Sql.Trim ("") ), L<S,S> ( p0 => Sql.TrimLeft(Sql.TrimRight(p0))) },
816
817 { M(() => Sql.Cosh(0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2) },
818 { M(() => Sql.Log (0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
819 { M(() => Sql.Log (0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
820 { M(() => Sql.Sinh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
821 { M(() => Sql.Tanh(0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
822 }},
823
824 #endregion
825
826 #region DB2
827
828 { "DB2", new Dictionary<MemberInfo,LambdaExpression> {
829 { M(() => Sql.Space (0) ), L<I?,S> ( p0 => Sql.Convert(Sql.VarChar(1000), Replicate(" ", p0))) },
830 { M(() => Sql.Stuff ("",0,0,"")), L<S,I?,I?,S,S>((p0,p1,p2,p3) => AltStuff(p0, p1, p2, p3)) },
831 { M(() => Sql.PadRight("",0,' ') ), L<S,I?,C?,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + VarChar(Replicate(p2, p1 - p0.Length), 1000)) },
832 { M(() => Sql.PadLeft ("",0,' ') ), L<S,I?,C?,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : VarChar(Replicate(p2, p1 - p0.Length), 1000) + p0) },
833
834 { M(() => Sql.ConvertTo<String>.From((Decimal)0)), L<Decimal,S>(p => Sql.TrimLeft(Sql.Convert<string,Decimal>(p), '0')) },
835 { M(() => Sql.ConvertTo<String>.From(Guid.Empty)), L<Guid, S>(p => Sql.Lower(
836 Sql.Substring(Hex(p), 7, 2) + Sql.Substring(Hex(p), 5, 2) + Sql.Substring(Hex(p), 3, 2) + Sql.Substring(Hex(p), 1, 2) + "-" +
837 Sql.Substring(Hex(p), 11, 2) + Sql.Substring(Hex(p), 9, 2) + "-" +
838 Sql.Substring(Hex(p), 15, 2) + Sql.Substring(Hex(p), 13, 2) + "-" +
839 Sql.Substring(Hex(p), 17, 4) + "-" +
840 Sql.Substring(Hex(p), 21, 12))) },
841
842 { M(() => Sql.Log(0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
843 { M(() => Sql.Log(0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
844 }},
845
846 #endregion
847
848 #region Informix
849
850 { "Informix", new Dictionary<MemberInfo,LambdaExpression> {
851 { M(() => Sql.Left ("",0) ), L<S,I?,S> ((p0,p1) => Sql.Substring(p0, 1, p1)) },
852 { M(() => Sql.Right("",0) ), L<S,I?,S> ((p0,p1) => Sql.Substring(p0, p0.Length - p1 + 1, p1)) },
853 { M(() => Sql.Stuff("",0,0,"")), L<S,I?,I?,S,S>((p0,p1,p2,p3) => AltStuff (p0, p1, p2, p3)) },
854 { M(() => Sql.Space(0) ), L<I?,S> ( p0 => Sql.PadRight (" ", p0, ' ')) },
855
856 { M(() => Sql.MakeDateTime(0,0,0)), L<I?,I?,I?,D?>((y,m,d) => Mdy(m, d, y)) },
857
858 { M(() => Sql.Cot (0) ), L<F?,F?> ( v => Sql.Cos(v) / Sql.Sin(v) ) },
859 { M(() => Sql.Cosh(0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2 ) },
860
861 { M(() => Sql.Degrees((Decimal?)0)), L<Decimal?,Decimal?>( v => (Decimal?)(v.Value * (180 / (Decimal)Math.PI))) },
862 { M(() => Sql.Degrees((Double?) 0)), L<Double?, Double?> ( v => (Double?) (v.Value * (180 / Math.PI))) },
863 { M(() => Sql.Degrees((Int16?) 0)), L<Int16?, Int16?> ( v => (Int16?) (v.Value * (180 / Math.PI))) },
864 { M(() => Sql.Degrees((Int32?) 0)), L<Int32?, Int32?> ( v => (Int32?) (v.Value * (180 / Math.PI))) },
865 { M(() => Sql.Degrees((Int64?) 0)), L<Int64?, Int64?> ( v => (Int64?) (v.Value * (180 / Math.PI))) },
866 { M(() => Sql.Degrees((SByte?) 0)), L<SByte?, SByte?> ( v => (SByte?) (v.Value * (180 / Math.PI))) },
867 { M(() => Sql.Degrees((Single?) 0)), L<Single?, Single?> ( v => (Single?) (v.Value * (180 / Math.PI))) },
868
869 { M(() => Sql.Log(0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
870 { M(() => Sql.Log(0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
871
872 { M(() => Sql.Sign((Decimal?)0)), L<Decimal?,I?>(p => p > 0 ? 1 : p < 0 ? -1 : 0 ) },
873 { M(() => Sql.Sign((Double?) 0)), L<Double?, I?>(p => p > 0 ? 1 : p < 0 ? -1 : 0 ) },
874 { M(() => Sql.Sign((Int16?) 0)), L<Int16?, I?>(p => p > 0 ? 1 : p < 0 ? -1 : 0 ) },
875 { M(() => Sql.Sign((Int32?) 0)), L<Int32?, I?>(p => p > 0 ? 1 : p < 0 ? -1 : 0 ) },
876 { M(() => Sql.Sign((Int64?) 0)), L<Int64?, I?>(p => p > 0 ? 1 : p < 0 ? -1 : 0 ) },
877 { M(() => Sql.Sign((SByte?) 0)), L<SByte?, I?>(p => p > 0 ? 1 : p < 0 ? -1 : 0 ) },
878 { M(() => Sql.Sign((Single?) 0)), L<Single?, I?>(p => p > 0 ? 1 : p < 0 ? -1 : 0 ) },
879
880 { M(() => Sql.Sinh(0)), L<F?,F?>( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
881 { M(() => Sql.Tanh(0)), L<F?,F?>( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) +Sql.Exp(-v))) },
882 }},
883
884 #endregion
885
886 #region Oracle
887
888 { "Oracle", new Dictionary<MemberInfo,LambdaExpression> {
889 { M(() => Sql.Left ("",0) ), L<S,I?,S> ((p0,p1) => Sql.Substring(p0, 1, p1)) },
890 { M(() => Sql.Right("",0) ), L<S,I?,S> ((p0,p1) => Sql.Substring(p0, p0.Length - p1 + 1, p1)) },
891 { M(() => Sql.Stuff("",0,0,"")), L<S,I?,I?,S,S>((p0,p1,p2,p3) => AltStuff(p0, p1, p2, p3)) },
892 { M(() => Sql.Space(0) ), L<I?,S> ( p0 => Sql.PadRight(" ", p0, ' ')) },
893
894 { M(() => Sql.ConvertTo<String>.From(Guid.Empty)), L<Guid,S>(p => Sql.Lower(
895 Sql.Substring(Sql.Convert2(Sql.Char(36), p), 7, 2) + Sql.Substring(Sql.Convert2(Sql.Char(36), p), 5, 2) + Sql.Substring(Sql.Convert2(Sql.Char(36), p), 3, 2) + Sql.Substring(Sql.Convert2(Sql.Char(36), p), 1, 2) + "-" +
896 Sql.Substring(Sql.Convert2(Sql.Char(36), p), 11, 2) + Sql.Substring(Sql.Convert2(Sql.Char(36), p), 9, 2) + "-" +
897 Sql.Substring(Sql.Convert2(Sql.Char(36), p), 15, 2) + Sql.Substring(Sql.Convert2(Sql.Char(36), p), 13, 2) + "-" +
898 Sql.Substring(Sql.Convert2(Sql.Char(36), p), 17, 4) + "-" +
899 Sql.Substring(Sql.Convert2(Sql.Char(36), p), 21, 12))) },
900
901 { M(() => Sql.Cot (0)), L<F?,F?>(v => Sql.Cos(v) / Sql.Sin(v) ) },
902 { M(() => Sql.Log10(0.0)), L<F?,F?>(v => Sql.Log(10, v) ) },
903
904 { M(() => Sql.Degrees((Decimal?)0)), L<Decimal?,Decimal?>( v => (Decimal?)(v.Value * (180 / (Decimal)Math.PI))) },
905 { M(() => Sql.Degrees((Double?) 0)), L<Double?, Double?> ( v => (Double?) (v.Value * (180 / Math.PI))) },
906 { M(() => Sql.Degrees((Int16?) 0)), L<Int16?, Int16?> ( v => (Int16?) (v.Value * (180 / Math.PI))) },
907 { M(() => Sql.Degrees((Int32?) 0)), L<Int32?, Int32?> ( v => (Int32?) (v.Value * (180 / Math.PI))) },
908 { M(() => Sql.Degrees((Int64?) 0)), L<Int64?, Int64?> ( v => (Int64?) (v.Value * (180 / Math.PI))) },
909 { M(() => Sql.Degrees((SByte?) 0)), L<SByte?, SByte?> ( v => (SByte?) (v.Value * (180 / Math.PI))) },
910 { M(() => Sql.Degrees((Single?) 0)), L<Single?, Single?> ( v => (Single?) (v.Value * (180 / Math.PI))) },
911 }},
912
913 #endregion
914
915 #region Firebird
916
917 { "Firebird", new Dictionary<MemberInfo,LambdaExpression> {
918 { M<S>(_ => Sql.Space(0 )), L<I?,S> ( p0 => Sql.PadRight(" ", p0, ' ')) },
919 { M<S>(s => Sql.Stuff(s, 0, 0, s)), L<S,I?,I?,S,S>((p0,p1,p2,p3) => AltStuff(p0, p1, p2, p3)) },
920
921 { M(() => Sql.Degrees((Decimal?)0)), L<Decimal?,Decimal?>( v => (Decimal?)(v.Value * 180 / DecimalPI())) },
922 { M(() => Sql.Degrees((Double?) 0)), L<Double?, Double?> ( v => (Double?) (v.Value * (180 / Math.PI))) },
923 { M(() => Sql.Degrees((Int16?) 0)), L<Int16?, Int16?> ( v => (Int16?) (v.Value * (180 / Math.PI))) },
924 { M(() => Sql.Degrees((Int32?) 0)), L<Int32?, Int32?> ( v => (Int32?) (v.Value * (180 / Math.PI))) },
925 { M(() => Sql.Degrees((Int64?) 0)), L<Int64?, Int64?> ( v => (Int64?) (v.Value * (180 / Math.PI))) },
926 { M(() => Sql.Degrees((SByte?) 0)), L<SByte?, SByte?> ( v => (SByte?) (v.Value * (180 / Math.PI))) },
927 { M(() => Sql.Degrees((Single?) 0)), L<Single?, Single?> ( v => (Single?) (v.Value * (180 / Math.PI))) },
928
929 { M(() => Sql.RoundToEven(0.0) ), L<F?,F?> ( v => (double)Sql.RoundToEven((decimal)v)) },
930 { M(() => Sql.RoundToEven(0.0,0)), L<F?,I?,F?>((v,p) => (double)Sql.RoundToEven((decimal)v, p)) },
931 }},
932
933 #endregion
934
935 #region MySql
936
937 { "MySql", new Dictionary<MemberInfo,LambdaExpression> {
938 { M<S>(s => Sql.Stuff(s, 0, 0, s)), L<S,I?,I?,S,S>((p0,p1,p2,p3) => AltStuff(p0, p1, p2, p3)) },
939
940 { M(() => Sql.Cosh(0)), L<F?,F?>(v => (Sql.Exp(v) + Sql.Exp(-v)) / 2) },
941 { M(() => Sql.Sinh(0)), L<F?,F?>(v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
942 { M(() => Sql.Tanh(0)), L<F?,F?>(v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
943 }},
944
945 #endregion
946
947 #region PostgreSQL
948
949 { "PostgreSQL", new Dictionary<MemberInfo,LambdaExpression> {
950 { M(() => Sql.Left ("",0) ), L<S,I?,S> ((p0,p1) => Sql.Substring(p0, 1, p1)) },
951 { M(() => Sql.Right("",0) ), L<S,I?,S> ((p0,p1) => Sql.Substring(p0, p0.Length - p1 + 1, p1)) },
952 { M(() => Sql.Stuff("",0,0,"")), L<S,I?,I?,S,S>((p0,p1,p2,p3) => AltStuff(p0, p1, p2, p3)) },
953 { M(() => Sql.Space(0) ), L<I?,S> ( p0 => Replicate(" ", p0)) },
954
955 { M(() => Sql.Cosh(0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2 ) },
956 { M(() => Sql.Round (0.0,0)), L<F?,I?,F?> ((v,p) => (double)Sql.Round ((decimal)v, p)) },
957 { M(() => Sql.RoundToEven(0.0) ), L<F?,F?> ( v => (double)Sql.RoundToEven((decimal)v)) },
958 { M(() => Sql.RoundToEven(0.0,0)), L<F?,I?,F?> ((v,p) => (double)Sql.RoundToEven((decimal)v, p)) },
959
960 { M(() => Sql.Log ((double)0,0)), L<F?,F?,F?> ((m,n) => (F?)Sql.Log((M)m,(M)n).Value ) },
961 { M(() => Sql.Sinh (0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
962 { M(() => Sql.Tanh (0) ), L<F?,F?> ( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
963
964 { M(() => Sql.Truncate(0.0) ), L<F?,F?> ( v => (double)Sql.Truncate((decimal)v)) },
965 }},
966
967 #endregion
968
969 #region SQLite
970
971 { "SQLite", new Dictionary<MemberInfo,LambdaExpression> {
972 { M(() => Sql.Stuff ("",0,0,"")), L<S,I?,I?,S,S>((p0,p1,p2,p3) => AltStuff(p0, p1, p2, p3)) },
973 { M(() => Sql.PadRight("",0,' ') ), L<S,I?,C?,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + Replicate(p2, p1 - p0.Length)) },
974 { M(() => Sql.PadLeft ("",0,' ') ), L<S,I?,C?,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : Replicate(p2, p1 - p0.Length) + p0) },
975
976 { M(() => Sql.MakeDateTime(0, 0, 0)), L<I?,I?,I?,D?>((y,m,d) => Sql.Convert(Sql.Date,
977 y.ToString() + "-" +
978 (m.ToString().Length == 1 ? "0" + m.ToString() : m.ToString()) + "-" +
979 (d.ToString().Length == 1 ? "0" + d.ToString() : d.ToString()))) },
980
981 { M(() => Sql.MakeDateTime(0, 0, 0, 0, 0, 0)), L<I?,I?,I?,I?,I?,I?,D?>((y,m,d,h,i,s) => Sql.Convert(Sql.DateTime2,
982 y.ToString() + "-" +
983 (m.ToString().Length == 1 ? "0" + m.ToString() : m.ToString()) + "-" +
984 (d.ToString().Length == 1 ? "0" + d.ToString() : d.ToString()) + " " +
985 (h.ToString().Length == 1 ? "0" + h.ToString() : h.ToString()) + ":" +
986 (i.ToString().Length == 1 ? "0" + i.ToString() : i.ToString()) + ":" +
987 (s.ToString().Length == 1 ? "0" + s.ToString() : s.ToString()))) },
988
989 { M(() => Sql.ConvertTo<String>.From(Guid.Empty)), L<Guid,S>(p => Sql.Lower(
990 Sql.Substring(Hex(p), 7, 2) + Sql.Substring(Hex(p), 5, 2) + Sql.Substring(Hex(p), 3, 2) + Sql.Substring(Hex(p), 1, 2) + "-" +
991 Sql.Substring(Hex(p), 11, 2) + Sql.Substring(Hex(p), 9, 2) + "-" +
992 Sql.Substring(Hex(p), 15, 2) + Sql.Substring(Hex(p), 13, 2) + "-" +
993 Sql.Substring(Hex(p), 17, 4) + "-" +
994 Sql.Substring(Hex(p), 21, 12))) },
995
996 { M(() => Sql.Log (0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
997 { M(() => Sql.Log (0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
998
999 { M(() => Sql.Truncate(0m)), L<M?,M?>( v => v >= 0 ? Sql.Floor(v) : Sql.Ceiling(v)) },
1000 { M(() => Sql.Truncate(0.0)), L<F?,F?>( v => v >= 0 ? Sql.Floor(v) : Sql.Ceiling(v)) },
1001 }},
1002
1003 #endregion
1004
1005 #region Sybase
1006
1007 { "Sybase", new Dictionary<MemberInfo,LambdaExpression> {
1008 { M(() => Sql.PadRight("",0,' ')), L<S,I?,C?,S>((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + Replicate(p2, p1 - p0.Length)) },
1009 { M(() => Sql.PadLeft ("",0,' ')), L<S,I?,C?,S>((p0,p1,p2) => p0.Length > p1 ? p0 : Replicate(p2, p1 - p0.Length) + p0) },
1010 { M(() => Sql.Trim ("") ), L<S,S> ( p0 => Sql.TrimLeft(Sql.TrimRight(p0))) },
1011
1012 { M(() => Sql.Cosh(0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2) },
1013 { M(() => Sql.Log (0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
1014 { M(() => Sql.Log (0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m)) },
1015
1016 { M(() => Sql.Degrees((Decimal?)0)), L<Decimal?,Decimal?>( v => (Decimal?)(v.Value * (180 / (Decimal)Math.PI))) },
1017 { M(() => Sql.Degrees((Double?) 0)), L<Double?, Double?> ( v => (Double?) (v.Value * (180 / Math.PI))) },
1018 { M(() => Sql.Degrees((Int16?) 0)), L<Int16?, Int16?> ( v => (Int16?) (v.Value * (180 / Math.PI))) },
1019 { M(() => Sql.Degrees((Int32?) 0)), L<Int32?, Int32?> ( v => (Int32?) (v.Value * (180 / Math.PI))) },
1020 { M(() => Sql.Degrees((Int64?) 0)), L<Int64?, Int64?> ( v => (Int64?) (v.Value * (180 / Math.PI))) },
1021 { M(() => Sql.Degrees((SByte?) 0)), L<SByte?, SByte?> ( v => (SByte?) (v.Value * (180 / Math.PI))) },
1022 { M(() => Sql.Degrees((Single?) 0)), L<Single?, Single?> ( v => (Single?) (v.Value * (180 / Math.PI))) },
1023
1024 { M(() => Sql.Sinh(0)), L<F?,F?>( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
1025 { M(() => Sql.Tanh(0)), L<F?,F?>( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
1026
1027 { M(() => Sql.Truncate(0m)), L<M?,M?>( v => v >= 0 ? Sql.Floor(v) : Sql.Ceiling(v)) },
1028 { M(() => Sql.Truncate(0.0)), L<F?,F?>( v => v >= 0 ? Sql.Floor(v) : Sql.Ceiling(v)) },
1029 }},
1030
1031 #endregion
1032
1033 #region Access
1034
1035 { "Access", new Dictionary<MemberInfo,LambdaExpression> {
1036 { M(() => Sql.Stuff ("",0,0,"")), L<S,I?,I?,S,S>((p0,p1,p2,p3) => AltStuff(p0, p1, p2, p3)) },
1037 { M(() => Sql.PadRight("",0,' ') ), L<S,I?,C?,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : p0 + Replicate(p2, p1 - p0.Length)) },
1038 { M(() => Sql.PadLeft ("",0,' ') ), L<S,I?,C?,S> ((p0,p1,p2) => p0.Length > p1 ? p0 : Replicate(p2, p1 - p0.Length) + p0) },
1039 { M(() => Sql.MakeDateTime(0,0,0)), L<I?,I?,I?,D?>((y,m,d) => MakeDateTime2(y, m, d)) },
1040
1041 { M(() => Sql.ConvertTo<String>.From(Guid.Empty)), L<Guid,S>(p => Sql.Lower(Sql.Substring(p.ToString(), 2, 36))) },
1042
1043 { M(() => Sql.Ceiling((Decimal)0)), L<Decimal?,Decimal?>(p => -Sql.Floor(-p) ) },
1044 { M(() => Sql.Ceiling((Double) 0)), L<Double?, Double?> (p => -Sql.Floor(-p) ) },
1045
1046 { M(() => Sql.Cot (0) ), L<F?,F?> ( v => Sql.Cos(v) / Sql.Sin(v) ) },
1047 { M(() => Sql.Cosh (0) ), L<F?,F?> ( v => (Sql.Exp(v) + Sql.Exp(-v)) / 2) },
1048 { M(() => Sql.Log (0m, 0)), L<M?,M?,M?>((m,n) => Sql.Log(n) / Sql.Log(m) ) },
1049 { M(() => Sql.Log (0.0,0)), L<F?,F?,F?>((m,n) => Sql.Log(n) / Sql.Log(m) ) },
1050 { M(() => Sql.Log10(0.0) ), L<F?,F?> ( n => Sql.Log(n) / Sql.Log(10.0) ) },
1051
1052 { M(() => Sql.Degrees((Decimal?)0)), L<Decimal?,Decimal?>( v => (Decimal?) ( v.Value * (180 / (Decimal)Math.PI))) },
1053 { M(() => Sql.Degrees((Double?) 0)), L<Double?, Double?> ( v => (Double?) ( v.Value * (180 / Math.PI))) },
1054 { M(() => Sql.Degrees((Int16?) 0)), L<Int16?, Int16?> ( v => (Int16?) AccessInt(AccessInt(v.Value) * (180 / Math.PI))) },
1055 { M(() => Sql.Degrees((Int32?) 0)), L<Int32?, Int32?> ( v => (Int32?) AccessInt(AccessInt(v.Value) * (180 / Math.PI))) },
1056 { M(() => Sql.Degrees((Int64?) 0)), L<Int64?, Int64?> ( v => (Int64?) AccessInt(AccessInt(v.Value) * (180 / Math.PI))) },
1057 { M(() => Sql.Degrees((SByte?) 0)), L<SByte?, SByte?> ( v => (SByte?) AccessInt(AccessInt(v.Value) * (180 / Math.PI))) },
1058 { M(() => Sql.Degrees((Single?) 0)), L<Single?, Single?> ( v => (Single?) ( v.Value * (180 / Math.PI))) },
1059
1060 { M(() => Sql.Round (0m) ), L<M?,M?> ( d => d - Sql.Floor(d) == 0.5m && Sql.Floor(d) % 2 == 0? Sql.Ceiling(d) : AccessRound(d, 0)) },
1061 { M(() => Sql.Round (0.0) ), L<F?,F?> ( d => d - Sql.Floor(d) == 0.5 && Sql.Floor(d) % 2 == 0? Sql.Ceiling(d) : AccessRound(d, 0)) },
1062 { M(() => Sql.Round (0m, 0)), L<M?,I?,M?>((v,p)=>
1063 p == 1 ? Sql.Round(v * 10) / 10 :
1064 p == 2 ? Sql.Round(v * 10) / 10 :
1065 p == 3 ? Sql.Round(v * 10) / 10 :
1066 p == 4 ? Sql.Round(v * 10) / 10 :
1067 p == 5 ? Sql.Round(v * 10) / 10 :
1068 Sql.Round(v * 10) / 10) },
1069 { M(() => Sql.Round (0.0,0)), L<F?,I?,F?>((v,p)=>
1070 p == 1 ? Sql.Round(v * 10) / 10 :
1071 p == 2 ? Sql.Round(v * 10) / 10 :
1072 p == 3 ? Sql.Round(v * 10) / 10 :
1073 p == 4 ? Sql.Round(v * 10) / 10 :
1074 p == 5 ? Sql.Round(v * 10) / 10 :
1075 Sql.Round(v * 10) / 10) },
1076 { M(() => Sql.RoundToEven(0m) ), L<M?,M?> ( v => AccessRound(v, 0))},
1077 { M(() => Sql.RoundToEven(0.0) ), L<F?,F?> ( v => AccessRound(v, 0))},
1078 { M(() => Sql.RoundToEven(0m, 0)), L<M?,I?,M?>((v,p)=> AccessRound(v, p))},
1079 { M(() => Sql.RoundToEven(0.0,0)), L<F?,I?,F?>((v,p)=> AccessRound(v, p))},
1080
1081 { M(() => Sql.Sinh(0)), L<F?,F?>( v => (Sql.Exp(v) - Sql.Exp(-v)) / 2) },
1082 { M(() => Sql.Tanh(0)), L<F?,F?>( v => (Sql.Exp(v) - Sql.Exp(-v)) / (Sql.Exp(v) + Sql.Exp(-v))) },
1083
1084 { M(() => Sql.Truncate(0m)), L<M?,M?>( v => v >= 0 ? Sql.Floor(v) : Sql.Ceiling(v)) },
1085 { M(() => Sql.Truncate(0.0)), L<F?,F?>( v => v >= 0 ? Sql.Floor(v) : Sql.Ceiling(v)) },
1086 }},
1087
1088 #endregion
1089 };
1090
1091 #region Sql specific
1092
1093 [CLSCompliant(false)]
1094 [SqlFunction("RTrim", 0)]
1095 public static string TrimRight(string str, char[] trimChars)
1096 {
1097 return str == null ? null : str.TrimEnd(trimChars);
1098 }
1099
1100 [CLSCompliant(false)]
1101 [SqlFunction("LTrim", 0)]
1102 public static string TrimLeft(string str, char[] trimChars)
1103 {
1104 return str == null ? null : str.TrimStart(trimChars);
1105 }
1106
1107 #endregion
1108
1109 #region Provider specific functions
1110
1111 [SqlFunction]
1112 static int? ConvertToCaseCompareTo(string str, string value)
1113 {
1114 return str == null || value == null ? (int?)null : str.CompareTo(value);
1115 }
1116
1117 // Access, DB2, Firebird, Informix, MySql, Oracle, PostgreSQL, SQLite
1118 //
1119 [SqlFunction]
1120 static string AltStuff(string str, int? startLocation, int? length, string value)
1121 {
1122 return Sql.Stuff(str, startLocation, length, value);
1123 }
1124
1125 // DB2
1126 //
1127 [SqlFunction]
1128 static string VarChar(object obj, int? size)
1129 {
1130 return obj.ToString();
1131 }
1132
1133 // DB2
1134 //
1135 [SqlFunction]
1136 static string Hex(Guid? guid)
1137 {
1138 return guid == null ? null : guid.ToString();
1139 }
1140
1141 #pragma warning disable 3019
1142
1143 // DB2, PostgreSQL, Access, MS SQL, SqlCe
1144 //
1145 [CLSCompliant(false)]
1146 [SqlFunction]
1147 [SqlFunction("DB2", "Repeat")]
1148 [SqlFunction("PostgreSQL", "Repeat")]
1149 [SqlFunction("Access", "String", 1, 0)]
1150 static string Replicate(string str, int? count)
1151 {
1152 if (str == null || count == null)
1153 return null;
1154
1155 var sb = new StringBuilder(str.Length * count.Value);
1156
1157 for (var i = 0; i < count; i++)
1158 sb.Append(str);
1159
1160 return sb.ToString();
1161 }
1162
1163 [CLSCompliant(false)]
1164 [SqlFunction]
1165 [SqlFunction("DB2", "Repeat")]
1166 [SqlFunction("PostgreSQL", "Repeat")]
1167 [SqlFunction("Access", "String", 1, 0)]
1168 static string Replicate(char? ch, int? count)
1169 {
1170 if (ch == null || count == null)
1171 return null;
1172
1173 var sb = new StringBuilder(count.Value);
1174
1175 for (var i = 0; i < count; i++)
1176 sb.Append(ch);
1177
1178 return sb.ToString();
1179 }
1180
1181 // MSSQL
1182 //
1183 [SqlFunction]
1184 static DateTime? DateAdd(Sql.DateParts part, int? number, int? days)
1185 {
1186 return days == null ? null : Sql.DateAdd(part, number, new DateTime(1900, 1, days.Value + 1));
1187 }
1188
1189 // MSSQL
1190 //
1191 [SqlFunction] static Decimal? Round(Decimal? value, int precision, int mode) { return 0; }
1192 [SqlFunction] static Double? Round(Double? value, int precision, int mode) { return 0; }
1193
1194 // Access
1195 //
1196 [SqlFunction("Access", "DateSerial")]
1197 static DateTime? MakeDateTime2(int? year, int? month, int? day)
1198 {
1199 return year == null || month == null || day == null?
1200 (DateTime?)null :
1201 new DateTime(year.Value, month.Value, day.Value);
1202 }
1203
1204 // Access
1205 //
1206 [CLSCompliant(false)]
1207 [SqlFunction("Int", 0)]
1208 static T AccessInt<T>(T value)
1209 {
1210 return value;
1211 }
1212
1213 // Access
1214 //
1215 [CLSCompliant(false)]
1216 [SqlFunction("Round", 0, 1)]
1217 static T AccessRound<T>(T value, int? precision) { return value; }
1218
1219 // Firebird
1220 //
1221 [SqlFunction("PI", ServerSideOnly = true)] static decimal DecimalPI() { return (decimal)Math.PI; }
1222 [SqlFunction("PI", ServerSideOnly = true)] static double DoublePI () { return Math.PI; }
1223
1224 // Informix
1225 //
1226 [SqlFunction]
1227 static DateTime? Mdy(int? month, int? day, int? year)
1228 {
1229 return year == null || month == null || day == null ?
1230 (DateTime?)null :
1231 new DateTime(year.Value, month.Value, day.Value);
1232 }
1233
1234 #endregion
1235
1236 #endregion
1237 }
1238 }