当前位置: 首页>>代码示例>>C#>>正文


C# Expression.Nullify方法代码示例

本文整理汇总了C#中System.Linq.Expressions.Expression.Nullify方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.Nullify方法的具体用法?C# Expression.Nullify怎么用?C# Expression.Nullify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Linq.Expressions.Expression的用法示例。


在下文中一共展示了Expression.Nullify方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NotEqualNullable

        public static Expression NotEqualNullable(Expression e1, Expression e2)
        {
            if (e1.Type.IsNullable() == e2.Type.IsNullable())
                return Expression.NotEqual(e1, e2);

            return Expression.NotEqual(e1.Nullify(), e2.Nullify());
        }
开发者ID:rondoo,项目名称:framework,代码行数:7,代码来源:SmartEqualizer.cs

示例2: EqualNullable

        public static Expression EqualNullable(Expression e1, Expression e2)
        {
            if (e1 == NewId || e2 == NewId)
                return False;

            if (e1.Type.IsNullable() == e2.Type.IsNullable())
                return Expression.Equal(e1, e2);

            return Expression.Equal(e1.Nullify(), e2.Nullify());
        }
开发者ID:rondoo,项目名称:framework,代码行数:10,代码来源:SmartEqualizer.cs

示例3: ParameterFactory

        public override MemberInitExpression ParameterFactory(Expression parameterName, SqlDbType sqlType, string udtTypeName, bool nullable, Expression value)
        {
            Expression valueExpr = Expression.Convert(IsDate(sqlType) ? Expression.Call(miAsserDateTime, value.Nullify()) : value, typeof(object));

            if (nullable)
                valueExpr = Expression.Condition(Expression.Equal(value, Expression.Constant(null, value.Type)),
                            Expression.Constant(DBNull.Value, typeof(object)),
                            valueExpr);

            NewExpression newExpr = Expression.New(typeof(SqlParameter).GetConstructor(new[] { typeof(string), typeof(object) }), parameterName, valueExpr);


            List<MemberBinding> mb = new List<MemberBinding>()
            {
                Expression.Bind(typeof(SqlParameter).GetProperty("IsNullable"), Expression.Constant(nullable)),
                Expression.Bind(typeof(SqlParameter).GetProperty("SqlDbType"), Expression.Constant(sqlType)),
            };

            if (sqlType == SqlDbType.Udt)
                mb.Add(Expression.Bind(typeof(SqlParameter).GetProperty("UdtTypeName"), Expression.Constant(udtTypeName)));

            return Expression.MemberInit(newExpr, mb);
        }
开发者ID:signumsoftware,项目名称:framework,代码行数:23,代码来源:SqlConnector.cs

示例4: GetCompareExpression

 public static Expression GetCompareExpression(FilterOperation operation, Expression left, Expression right, bool inMemory = false)
 {
     switch (operation)
     {
         case FilterOperation.EqualTo: return Expression.Equal(left, right);
         case FilterOperation.DistinctTo: 
             {
                 var t = left.Type.UnNullify();
                 var mi = t.IsValueType ? miDistinctNullable : miDistinct;
                 return Expression.Call(mi.MakeGenericMethod(t), left.Nullify(), right.Nullify());
             }
         case FilterOperation.GreaterThan: return Expression.GreaterThan(left, right);
         case FilterOperation.GreaterThanOrEqual: return Expression.GreaterThanOrEqual(left, right);
         case FilterOperation.LessThan: return Expression.LessThan(left, right);
         case FilterOperation.LessThanOrEqual: return Expression.LessThanOrEqual(left, right);
         case FilterOperation.Contains: return Expression.Call(Fix(left, inMemory), miContains, right);
         case FilterOperation.StartsWith: return Expression.Call(Fix(left, inMemory), miStartsWith, right);
         case FilterOperation.EndsWith: return Expression.Call(Fix(left, inMemory), miEndsWith, right);
         case FilterOperation.Like: return Expression.Call(miLike, Fix(left, inMemory), right);
         case FilterOperation.NotContains: return Expression.Not(Expression.Call(Fix(left, inMemory), miContains, right));
         case FilterOperation.NotStartsWith: return Expression.Not(Expression.Call(Fix(left, inMemory), miStartsWith, right));
         case FilterOperation.NotEndsWith: return Expression.Not(Expression.Call(Fix(left, inMemory), miEndsWith, right));
         case FilterOperation.NotLike: return Expression.Not(Expression.Call(miLike, Fix(left, inMemory), right));
         default:
             throw new InvalidOperationException("Unknown operation {0}".Formato(operation));
     }
 }
开发者ID:nuub666,项目名称:framework,代码行数:27,代码来源:QueryUtils.cs

示例5: ParameterFactory

        public override MemberInitExpression ParameterFactory(Expression parameterName, SqlDbType sqlType, string udtTypeName, bool nullable, Expression value)
        {
            Expression valueExpr = Expression.Convert(IsDate(sqlType) ? Expression.Call(miAsserDateTime, value.Nullify()) : value, typeof(object));

            if (nullable)
                valueExpr = Expression.Condition(Expression.Equal(value, Expression.Constant(null, value.Type)),
                            Expression.Constant(DBNull.Value, typeof(object)),
                            valueExpr);

            NewExpression newExpr = Expression.New(typeof(SqlCeParameter).GetConstructor(new[] { typeof(string), typeof(object) }), parameterName, valueExpr);


            List<MemberBinding> mb = new List<MemberBinding>()
            {
                Expression.Bind(typeof(SqlCeParameter).GetProperty("IsNullable"), Expression.Constant(nullable)),
                Expression.Bind(typeof(SqlCeParameter).GetProperty("SqlDbType"), Expression.Constant(sqlType)),
            };

            if (sqlType == SqlDbType.Udt)
                throw new InvalidOperationException("User Defined Tyeps not supported on SQL Server Compact ({0})".FormatWith(udtTypeName));

            return Expression.MemberInit(newExpr, mb);
        }
开发者ID:rondoo,项目名称:framework,代码行数:23,代码来源:SqlCeConnector.cs

示例6: EqualNullableGroupBy

 public static Expression EqualNullableGroupBy(Expression e1, Expression e2)
 {
     return Expression.Or(Expression.Equal(e1.Nullify(), e2.Nullify()),
         Expression.And(new IsNullExpression(e1), new IsNullExpression(e2)));
 }
开发者ID:rondoo,项目名称:framework,代码行数:5,代码来源:SmartEqualizer.cs


注:本文中的System.Linq.Expressions.Expression.Nullify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。