• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DbExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DbExpression的典型用法代码示例。如果您正苦于以下问题:C# DbExpression类的具体用法?C# DbExpression怎么用?C# DbExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DbExpression类属于命名空间,在下文中一共展示了DbExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Binding

 internal Binding(Expression linqExpression, DbExpression cqtExpression)
 {
     //Contract.Requires(linqExpression != null);
     //Contract.Requires(cqtExpression != null);
     LinqExpression = linqExpression;
     CqtExpression = cqtExpression;
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:Binding.cs


示例2: DbDeleteCommandTree

        internal DbDeleteCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, DbExpressionBinding target, DbExpression predicate)
            : base(metadata, dataSpace, target)
        {
            EntityUtil.CheckArgumentNull(predicate, "predicate");

            this._predicate = predicate;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:DbDeleteCommandTree.cs


示例3: GenerateReturningSql

    protected virtual SelectStatement GenerateReturningSql(DbModificationCommandTree tree, DbExpression returning)
    {      
      SelectStatement select = base.GenerateReturningSql(tree, returning);      

      ListFragment where = new ListFragment();

      EntitySetBase table = ((DbScanExpression)tree.Target.Expression).Target;
      bool foundIdentity = false;
      where.Append(" row_count() > 0");
      foreach (EdmMember keyMember in table.ElementType.KeyMembers)
      {
        SqlFragment value;
        if (!values.TryGetValue(keyMember, out value))
        {
          if (foundIdentity)
            throw new NotSupportedException();
          foundIdentity = true;
          value = new LiteralFragment("last_insert_id()");
        }
        where.Append(String.Format(" AND `{0}`=", keyMember));
        where.Append(value);
      }
      select.Where = where;      
      return select;
    }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:25,代码来源:InsertGenerator.cs


示例4: StripInvalidConvert

        public static DbExpression StripInvalidConvert(DbExpression exp)
        {
            DbConvertExpression convertExpression = exp as DbConvertExpression;

            if (convertExpression == null)
                return exp;

            if (convertExpression.Type.IsEnum)
            {
                //(enumType)123
                if (typeof(int) == convertExpression.Operand.Type)
                    return StripInvalidConvert(convertExpression.Operand);

                DbConvertExpression newExp = new DbConvertExpression(typeof(int), convertExpression.Operand);
                return StripInvalidConvert(newExp);
            }

            Type unType;

            //(int?)123
            if (Utils.IsNullable(convertExpression.Type, out unType))//可空类型转换
            {
                if (unType == convertExpression.Operand.Type)
                    return StripInvalidConvert(convertExpression.Operand);

                DbConvertExpression newExp = new DbConvertExpression(unType, convertExpression.Operand);
                return StripInvalidConvert(newExp);
            }

            //(int)enumTypeValue
            if (exp.Type == typeof(int))
            {
                //(int)enumTypeValue
                if (convertExpression.Operand.Type.IsEnum)
                    return StripInvalidConvert(convertExpression.Operand);

                //(int)NullableEnumTypeValue
                if (Utils.IsNullable(convertExpression.Operand.Type, out unType) && unType.IsEnum)
                    return StripInvalidConvert(convertExpression.Operand);
            }

            //float long double and so on
            if (exp.Type.IsValueType)
            {
                //(long)NullableValue
                if (Utils.IsNullable(convertExpression.Operand.Type, out unType) && unType == exp.Type)
                    return StripInvalidConvert(convertExpression.Operand);
            }

            if (convertExpression.Type == convertExpression.Operand.Type)
            {
                return StripInvalidConvert(convertExpression.Operand);
            }

            //如果是子类向父类转换
            if (exp.Type.IsAssignableFrom(convertExpression.Operand.Type))
                return StripInvalidConvert(convertExpression.Operand);

            return convertExpression;
        }
开发者ID:Gilgamash,项目名称:Chloe,代码行数:60,代码来源:DbExpressionHelper.cs


示例5: Process

        private DbExpression Process(DbExpression expression)
        {
            DebugCheck.NotNull(expression);

            expression = VisitExpression(expression);
            return expression;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:7,代码来源:PatternMatchRuleProcessor.cs


示例6: GetReturningFields

        public static FieldDescription[] GetReturningFields(
            DbExpression returning)
        {
            // Find the returning properties
            DbNewInstanceExpression returnExpression = returning as DbNewInstanceExpression;

            if (returnExpression == null)
            {
                throw new NotSupportedException(
                    "The type of the Returning properties is not DbNewInstanceExpression");
            }

            List<FieldDescription> result = new List<FieldDescription>();

            // Add the returning property names
            foreach (DbPropertyExpression propertyExpression in returnExpression.Arguments)
            {
                PrimitiveType propertyType = 
                    propertyExpression.ResultType.EdmType as PrimitiveType;

                string name = propertyExpression.Property.GetColumnName();
                Type type = propertyType.ClrEquivalentType;

                result.Add(new FieldDescription(name, type));
            }

            return result.ToArray();
        }
开发者ID:DeadlyEmbrace,项目名称:effort,代码行数:28,代码来源:DbCommandActionHelper.cs


示例7: DbUnaryExpression

        internal DbUnaryExpression(DbExpressionKind kind, TypeUsage resultType, DbExpression argument)
            : base(kind, resultType)
        {
            DebugCheck.NotNull(argument);

            _argument = argument;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:DbUnaryExpression.cs


示例8: GenerateReturningSql

    protected override SelectStatement GenerateReturningSql(DbModificationCommandTree tree, DbExpression returning)
    {      
      SelectStatement select = base.GenerateReturningSql(tree, returning);      

      ListFragment where = new ListFragment();

      EntitySetBase table = ((DbScanExpression)tree.Target.Expression).Target;
      bool foundIdentity = false;
      where.Append(" row_count() > 0");
      foreach (EdmMember keyMember in table.ElementType.KeyMembers)
      {
        SqlFragment value;
        if (!values.TryGetValue(keyMember, out value))
        {
          if (foundIdentity)
            throw new NotSupportedException();
          foundIdentity = true;
          PrimitiveTypeKind type = ((PrimitiveType)keyMember.TypeUsage.EdmType.BaseType).PrimitiveTypeKind;
          if ((type == PrimitiveTypeKind.Byte) || (type == PrimitiveTypeKind.SByte) ||
              (type == PrimitiveTypeKind.Int16) || (type == PrimitiveTypeKind.Int32) ||
              (type == PrimitiveTypeKind.Int64))
          {
            value = new LiteralFragment("last_insert_id()");
	  }
          else if (keyMember.TypeUsage.EdmType.BaseType.Name == "Guid")
            value = new LiteralFragment(string.Format("ANY(SELECT guid FROM tmpIdentity_{0})", (table as MetadataItem).MetadataProperties["Table"].Value));
        }
        where.Append(String.Format(" AND `{0}`=", keyMember));
        where.Append(value);
      }
      select.Where = where;      
      return select;
    }
开发者ID:Nicholi,项目名称:mysql-connector-net,代码行数:33,代码来源:InsertGenerator.cs


示例9: DbUnaryExpression

        internal DbUnaryExpression(DbExpressionKind kind, TypeUsage resultType, DbExpression argument)
            : base(kind, resultType)
        {
            Debug.Assert(argument != null, "DbUnaryExpression.Argument cannot be null");

            _argument = argument;
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:7,代码来源:DbUnaryExpression.cs


示例10: DbSetClause

 internal DbSetClause(DbExpression targetProperty, DbExpression sourceValue)
 {
     //Contract.Requires(targetProperty != null);
     //Contract.Requires(sourceValue != null);
     _prop = targetProperty;
     _val = sourceValue;
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:DbSetClause.cs


示例11: TryRewrite

        internal static bool TryRewrite(DbQueryCommandTree tree, Span span, MergeOption mergeOption, AliasGenerator aliasGenerator, out DbExpression newQuery, out SpanIndex spanInfo)
        {
            newQuery = null;
            spanInfo = null;

            ObjectSpanRewriter rewriter = null;
            bool requiresRelationshipSpan = Span.RequiresRelationshipSpan(mergeOption);

            // Potentially perform a rewrite for span.
            // Note that the public 'Span' property is NOT used to retrieve the Span instance
            // since this forces creation of a Span object that may not be required.
            if (span != null && span.SpanList.Count > 0)
            {
                rewriter = new ObjectFullSpanRewriter(tree, tree.Query, span, aliasGenerator);
            }
            else if (requiresRelationshipSpan)
            {
                rewriter = new ObjectSpanRewriter(tree, tree.Query, aliasGenerator);
            }

            if (rewriter != null)
            {
                rewriter.RelationshipSpan = requiresRelationshipSpan;
                newQuery = rewriter.RewriteQuery();
                if (newQuery != null)
                {
                    Debug.Assert(rewriter.SpanIndex != null || tree.Query.ResultType.EdmEquals(newQuery.ResultType), "Query was rewritten for Span but no SpanIndex was created?");
                    spanInfo = rewriter.SpanIndex;
                }
            }

            return (spanInfo != null);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:33,代码来源:ObjectSpanRewriter.cs


示例12: DbGroupExpressionBinding

 internal DbGroupExpressionBinding(
     DbExpression input, DbVariableReferenceExpression inputRef, DbVariableReferenceExpression groupRef)
 {
     _expr = input;
     _varRef = inputRef;
     _groupVarRef = groupRef;
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:7,代码来源:DbGroupExpressionBinding.cs


示例13: DbDeleteCommandTree

        /// <summary>
        /// Initializes a new instance of the <see cref="DbDeleteCommandTree"/> class.
        /// </summary>
        /// <param name="metadata">The model this command will operate on.</param>
        /// <param name="dataSpace">The data space.</param>
        /// <param name="target">The target table for the data manipulation language (DML) operation.</param>
        /// <param name="predicate">A predicate used to determine which members of the target collection should be deleted.</param>
        public DbDeleteCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, DbExpressionBinding target, DbExpression predicate)
            : base(metadata, dataSpace, target)
        {
            DebugCheck.NotNull(predicate);

            _predicate = predicate;
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:14,代码来源:DbDeleteCommandTree.cs


示例14: DbDeleteCommandTree

        internal DbDeleteCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, DbExpressionBinding target, DbExpression predicate)
            : base(metadata, dataSpace, target)
        {
            Contract.Requires(predicate != null);

            _predicate = predicate;
        }
开发者ID:junxy,项目名称:entityframework,代码行数:7,代码来源:DbDeleteCommandTree.cs


示例15: ProcessRules

        private static Tuple<DbExpression, DbExpressionRule.ProcessedAction> ProcessRules(
            DbExpression expression, List<DbExpressionRule> rules)
        {
            // Considering each rule in the rule set in turn, if the rule indicates that it can process the
            // input expression, call TryProcess to attempt processing. If successful, take the action specified
            // by the rule's OnExpressionProcessed action, which may involve returning the action and the result
            // expression so that processing can be reset or halted.

            for (var idx = 0; idx < rules.Count; idx++)
            {
                var currentRule = rules[idx];
                if (currentRule.ShouldProcess(expression))
                {
                    DbExpression result;
                    if (currentRule.TryProcess(expression, out result))
                    {
                        if (currentRule.OnExpressionProcessed
                            != DbExpressionRule.ProcessedAction.Continue)
                        {
                            return Tuple.Create(result, currentRule.OnExpressionProcessed);
                        }
                        else
                        {
                            expression = result;
                        }
                    }
                }
            }
            return Tuple.Create(expression, DbExpressionRule.ProcessedAction.Continue);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:30,代码来源:DbExpressionRuleProcessingVisitor.cs


示例16: StripNull

            internal static CqtExpression StripNull(LinqExpression sourceExpression, 
                DbExpression inputExpression, DbExpression outputExpression, bool useDatabaseNullSemantics)
            {
                if (sourceExpression.IsNullConstant())
                {
                    return DbExpressionBuilder.Constant(string.Empty);
                }

                if (sourceExpression.NodeType == ExpressionType.Constant)
                {
                    return outputExpression;
                }

                if (useDatabaseNullSemantics)
                {
                    return outputExpression;
                }

                // converts evaluated null values to empty string, nullable primitive properties etc.
                var castNullToEmptyString = DbExpressionBuilder.Case(
                    new[] { inputExpression.IsNull() },
                    new[] { DbExpressionBuilder.Constant(string.Empty) },
                    outputExpression);
                return castNullToEmptyString;
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:StringTranslatorUtil.cs


示例17: DbExpressionBinding

        internal DbExpressionBinding(DbExpression input, DbVariableReferenceExpression varRef)
        {
            Debug.Assert(input != null, "DbExpressionBinding input cannot be null");
            Debug.Assert(varRef != null, "DbExpressionBinding variable cannot be null");

            _expr = input;
            _varRef = varRef;
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:8,代码来源:DbExpressionBinding.cs


示例18: ObjectSpanRewriter

        /// <summary>
        ///     Constructs a new ObjectSpanRewriter that will attempt to apply spanning to the specified query
        ///     (represented as a DbExpression) when <see cref="RewriteQuery" /> is called.
        /// </summary>
        /// <param name="toRewrite">
        ///     A <see cref="DbExpression" /> representing the query to span.
        /// </param>
        internal ObjectSpanRewriter(DbCommandTree tree, DbExpression toRewrite, AliasGenerator aliasGenerator)
        {
            DebugCheck.NotNull(toRewrite);

            _toRewrite = toRewrite;
            _tree = tree;
            _aliasGenerator = aliasGenerator;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:15,代码来源:ObjectSpanRewriter.cs


示例19: Binding

        internal Binding(Expression linqExpression, DbExpression cqtExpression)
        {
            DebugCheck.NotNull(linqExpression);
            DebugCheck.NotNull(cqtExpression);

            LinqExpression = linqExpression;
            CqtExpression = cqtExpression;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:Binding.cs


示例20: DbSortClause

        internal DbSortClause(DbExpression key, bool asc, string collation)
        {
            DebugCheck.NotNull(key);

            _expr = key;
            _asc = asc;
            _coll = collation;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:8,代码来源:DbSortClause.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DbExpressionKind类代码示例发布时间:2022-05-24
下一篇:
C# DbEntityEntry类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap