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


C# DbExpression类代码示例

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


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


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