Пример #1
0
        /// <summary>
        /// Creates the command definition wrapper for a given provider manifest and command tree.
        /// </summary>
        /// <param name="providerManifest">The provider manifest.</param>
        /// <param name="commandTree">The command tree.</param>
        /// <returns><see cref="DbCommandDefinition"/> object.</returns>
        protected override System.Data.Entity.Core.Common.DbCommandDefinition CreateDbCommandDefinition(System.Data.Entity.Core.Common.DbProviderManifest providerManifest, System.Data.Entity.Core.Common.CommandTrees.DbCommandTree commandTree)
        {
            var wrapperManifest = (DbProviderManifestWrapper)providerManifest;
            var createDbCommandDefinitionFunction = this.GetCreateDbCommandDefinitionFunction(wrapperManifest.WrappedProviderManifestInvariantName);

            System.Data.Entity.Core.Common.DbCommandDefinition definition = createDbCommandDefinitionFunction(wrapperManifest.WrappedProviderManifest, commandTree);
            return(this.CreateCommandDefinitionWrapper(definition, commandTree));
        }
Пример #2
0
 private static void PopulateBinaryParameter(
     DbParameter parameter,
     TypeUsage type,
     DbType dbType,
     bool isOutParam)
 {
     parameter.DbType = dbType;
     DbCommandDefinition.SetParameterSize(parameter, type, isOutParam);
 }
Пример #3
0
        private static void PopulateStringParameter(
            DbParameter parameter,
            TypeUsage type,
            bool isOutParam)
        {
            bool isUnicode     = true;
            bool isFixedLength = false;

            if (!TypeHelpers.TryGetIsFixedLength(type, out isFixedLength))
            {
                isFixedLength = false;
            }
            if (!TypeHelpers.TryGetIsUnicode(type, out isUnicode))
            {
                isUnicode = true;
            }
            parameter.DbType = !isFixedLength ? (isUnicode ? DbType.String : DbType.AnsiString) : (isUnicode ? DbType.StringFixedLength : DbType.AnsiStringFixedLength);
            DbCommandDefinition.SetParameterSize(parameter, type, isOutParam);
        }
Пример #4
0
        internal static void PopulateParameterFromTypeUsage(
            DbParameter parameter,
            TypeUsage type,
            bool isOutParam)
        {
            parameter.IsNullable = TypeSemantics.IsNullable(type);
            DbType dbType;

            if (!Helper.IsPrimitiveType(type.EdmType) || !DbCommandDefinition.TryGetDbTypeFromPrimitiveType((PrimitiveType)type.EdmType, out dbType))
            {
                return;
            }
            switch (dbType)
            {
            case DbType.Binary:
                DbCommandDefinition.PopulateBinaryParameter(parameter, type, dbType, isOutParam);
                break;

            case DbType.DateTime:
            case DbType.Time:
            case DbType.DateTimeOffset:
                DbCommandDefinition.PopulateDateTimeParameter(parameter, type, dbType);
                break;

            case DbType.Decimal:
                DbCommandDefinition.PopulateDecimalParameter(parameter, type, dbType);
                break;

            case DbType.String:
                DbCommandDefinition.PopulateStringParameter(parameter, type, isOutParam);
                break;

            default:
                parameter.DbType = dbType;
                break;
            }
        }
 /// <summary>
 ///     Create the default DbCommandDefinition object based on the prototype command
 ///     This method is intended for provider writers to build a default command definition
 ///     from a command.
 ///     Note: This will clone the prototype
 /// </summary>
 /// <param name="prototype"> the prototype command </param>
 /// <returns> an executable command definition object </returns>
 public virtual DbCommandDefinition CreateCommandDefinition(DbCommand prototype)
 {
     return(DbCommandDefinition.CreateCommandDefinition(prototype));
 }
Пример #6
0
 /// <summary>
 /// Creates the command definition wrapper.
 /// </summary>
 /// <param name="wrappedCommandDefinition">The wrapped command definition.</param>
 /// <param name="commandTree">The command tree.</param>
 /// <returns><see cref="DbCommandDefinitionWrapper"/> object.</returns>
 public virtual DbCommandDefinitionWrapper CreateCommandDefinitionWrapper(System.Data.Entity.Core.Common.DbCommandDefinition wrappedCommandDefinition, System.Data.Entity.Core.Common.CommandTrees.DbCommandTree commandTree)
 {
     return(new DbCommandDefinitionWrapper(wrappedCommandDefinition, commandTree, (cmd, def) => EFDbCommandFactory.GetCommandWrapper(cmd, def)));
 }
Пример #7
0
 internal EFCachingCommandDefinition(System.Data.Entity.Core.Common.DbCommandDefinition wrappedCommandDefinition, System.Data.Entity.Core.Common.CommandTrees.DbCommandTree commandTree)
     : base(wrappedCommandDefinition, commandTree, (cmd, def) => EFDbCommandFactory.GetCommandWrapper(cmd, def))
 {
     this.GetAffectedEntitySets(commandTree);
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the DbCommandDefinitionWrapper class.
 /// </summary>
 /// <param name="wrappedCommandDefinition">The wrapped command definition.</param>
 /// <param name="commandTree">The command tree.</param>
 /// <param name="commandCreator">The command creator delegate.</param>
 public DbCommandDefinitionWrapper(System.Data.Entity.Core.Common.DbCommandDefinition wrappedCommandDefinition, System.Data.Entity.Core.Common.CommandTrees.DbCommandTree commandTree, Func <DbCommand, DbCommandDefinitionWrapper, DbCommand> commandCreator)
 {
     this.wrappedCommandDefinition = wrappedCommandDefinition;
     this.commandTree    = commandTree;
     this.commandCreator = commandCreator;
 }