示例#1
0
        static Database()
        {
            For <DateTime>(b => {
                b.Property(x => x.Day, exp => FuncInternal.DatePart(ExtractField.Day, exp));
                b.Property(x => x.Month, exp => FuncInternal.DatePart(ExtractField.Month, exp));
                b.Property(x => x.Year, exp => FuncInternal.DatePart(ExtractField.Year, exp));
                b.Property(x => x.Hour, exp => FuncInternal.DatePart(ExtractField.Hour, exp));
                b.Property(x => x.Minute, exp => FuncInternal.DatePart(ExtractField.Minute, exp));
                b.Property(x => x.Second, exp => FuncInternal.DatePart(ExtractField.Second, exp));
                b.Property(x => x.Millisecond, exp => FuncInternal.DatePart(ExtractField.Milliseconds, exp));
                b.Property(x => x.Date, FuncInternal.Date);
            });

            For <string>(b => {
                b.Method <int, int, string>((x, start, cnt) => x.Substring(start, cnt), ExpressionBuilders.Substring);
                b.Method <string, bool>((x, str) => x.StartsWith(str), ExpressionBuilders.StartsWith);
                b.Method <string, bool>((x, str) => x.EndsWith(str), ExpressionBuilders.EndsWith);
                b.Method <string, bool>((x, str) => x.Contains(str), ExpressionBuilders.Contains);
                b.Method <string>(x => x.ToUpper(), ExpressionBuilders.ToUpper);
                b.Method <string>(x => x.ToLower(), ExpressionBuilders.ToLower);

                b.Method <string, bool>((x, str) => x.PgLike(str), ExpressionBuilders.Like);
                b.Method <string, bool>((x, str) => x.PgILike(str), ExpressionBuilders.ILike);
                b.Method <string, bool>((x, str) => x.PgRawLike(str), ExpressionBuilders.RawLike);
                b.Method <string, bool>((x, str) => x.PgRawILike(str), ExpressionBuilders.RawILike);
            });

            MethodsDatabase.Optimize();
            PropertiesDatabase.Optimize();
        }
示例#2
0
 public void Property(Expression <Func <T, object> > prop, Func <TypedExpression, TypedExpression> processor)
 {
     PropertiesDatabase.Register(prop, processor);
 }