static LegacyDbProviderManifestWrapperTests() { LegacyProviderManifest = ((Legacy.DbProviderServices) ((IServiceProvider)Legacy.DbProviderFactories.GetFactory("System.Data.SqlClient")) .GetService(typeof(Legacy.DbProviderServices))) .GetProviderManifest("2008"); ProviderManifestWrapper = new LegacyDbProviderManifestWrapper(LegacyProviderManifest); const string emptyCsdl = @"<Schema xmlns=""http://schemas.microsoft.com/ado/2009/11/edm"" Namespace=""dummy"" />"; using (var reader = XmlReader.Create(new StringReader(emptyCsdl))) { EdmPrimitiveTypes = new EdmItemCollection(new[] { reader }).GetItems <PrimitiveType>().ToDictionary(t => t.Name, t => t); } using (var reader = XmlReader.Create(new StringReader(emptyCsdl))) { LegacyEdmPrimitiveTypes = new LegacyMetadata.EdmItemCollection(new[] { reader }) .GetItems <LegacyMetadata.PrimitiveType>() .ToDictionary(t => t.Name, t => t); } }
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, System.Data.Common.CommandTrees.DbCommandTree commandTree) { if (providerManifest == null) throw new ArgumentNullException("providerManifest"); if (commandTree == null) throw new ArgumentNullException("commandTree"); NuoDbCommand command = new NuoDbCommand(PrepareTypeCoercions(commandTree)); List<DbParameter> parameters; CommandType commandType; command.CommandText = SqlGenerator.GenerateSql(commandTree, out parameters, out commandType); command.CommandType = commandType; // Get the function (if any) implemented by the command tree since this influences our interpretation of parameters EdmFunction function = null; if (commandTree is DbFunctionCommandTree) { function = ((DbFunctionCommandTree)commandTree).EdmFunction; } foreach (KeyValuePair<string, TypeUsage> queryParameter in commandTree.Parameters) { NuoDbParameter parameter; // Use the corresponding function parameter TypeUsage where available (currently, the SSDL facets and // type trump user-defined facets and type in the EntityCommand). FunctionParameter functionParameter; if (null != function && function.Parameters.TryGetValue(queryParameter.Key, false, out functionParameter)) { parameter = CreateSqlParameter(functionParameter.Name, functionParameter.TypeUsage, functionParameter.Mode, DBNull.Value); } else { parameter = CreateSqlParameter(queryParameter.Key, queryParameter.Value, ParameterMode.In, DBNull.Value); } command.Parameters.Add(parameter); } // Now add parameters added as part of SQL gen (note: this feature is only safe for DML SQL gen which // does not support user parameters, where there is no risk of name collision) if (null != parameters && 0 < parameters.Count) { if (!(commandTree is DbInsertCommandTree) && !(commandTree is DbUpdateCommandTree) && !(commandTree is DbDeleteCommandTree)) { throw new InvalidOperationException("SqlGenParametersNotPermitted"); } foreach (DbParameter parameter in parameters) { command.Parameters.Add(parameter); } } return CreateCommandDefinition(command); }
static LegacyDbProviderManifestWrapperTests() { LegacyProviderManifest = ((Legacy.DbProviderServices) ((IServiceProvider)Legacy.DbProviderFactories.GetFactory("System.Data.SqlClient")) .GetService(typeof(Legacy.DbProviderServices))) .GetProviderManifest("2008"); ProviderManifestWrapper = new LegacyDbProviderManifestWrapper(LegacyProviderManifest); const string emptyCsdl = @"<Schema xmlns=""http://schemas.microsoft.com/ado/2009/11/edm"" Namespace=""dummy"" />"; using (var reader = XmlReader.Create(new StringReader(emptyCsdl))) { EdmPrimitiveTypes = new EdmItemCollection(new[] { reader }).GetItems<PrimitiveType>().ToDictionary(t => t.Name, t => t); } using (var reader = XmlReader.Create(new StringReader(emptyCsdl))) { LegacyEdmPrimitiveTypes = new LegacyMetadata.EdmItemCollection(new[] { reader }) .GetItems<LegacyMetadata.PrimitiveType>() .ToDictionary(t => t.Name, t => t); } }
/// <summary> /// create the database command definition. /// </summary> /// <param name="providerManifest">The provider manifest.</param> /// <param name="commandTree">The command tree.</param> /// <returns>the command definition.</returns> protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, System.Data.Common.CommandTrees.DbCommandTree commandTree) { var cmdDef = _wrapped.CreateCommandDefinition(providerManifest, commandTree); var cmd = cmdDef.CreateCommand(); Debug.Assert(cmd != null, "cmd != null"); return CreateCommandDefinition(new ProfiledDbCommand(cmd, cmd.Connection, _profiler)); }
/// <summary> /// Create a Command Definition object, given the connection and command tree /// </summary> /// <param name="connection">connection to the underlying provider</param> /// <param name="commandTree">command tree for the statement</param> /// <returns>an exectable command definition object</returns> /// <exception cref="ArgumentNullException">connection and commandTree arguments must not be null</exception> protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) { EntityUtil.CheckArgumentNull(providerManifest, "providerManifest"); EntityUtil.CheckArgumentNull(commandTree, "commandTree"); StoreItemCollection storeMetadata = (StoreItemCollection)commandTree.MetadataWorkspace.GetItemCollection(DataSpace.SSpace); return this.CreateCommandDefinition(storeMetadata.StoreProviderFactory, commandTree); }
/// <summary> /// Creates the provider manifest wrapper. /// </summary> /// <param name="providerInvariantName">Provider invariant name.</param> /// <param name="providerManifest">The provider manifest to be wrapped.</param> /// <returns><see cref="DbProviderManifest"/> wrapper for given provider invariant name wrapping given provider manifest.</returns> public virtual DbProviderManifest CreateProviderManifest(string providerInvariantName, DbProviderManifest providerManifest) { return new DbProviderManifestWrapper( ProviderInvariantName, providerInvariantName, providerManifest); }
/// <summary> /// Create a Command Definition object, given the connection and command tree /// </summary> /// <param name="providerManifest">provider manifest that was determined from metadata</param> /// <param name="commandTree">command tree for the statement</param> /// <returns>an exectable command definition object</returns> protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) { Debug.Assert(providerManifest != null, "CreateCommandDefinition passed null provider manifest to CreateDbCommandDefinition?"); Debug.Assert(commandTree != null, "CreateCommandDefinition did not validate commandTree argument?"); DbCommand prototype = CreateCommand(providerManifest, commandTree); DbCommandDefinition result = this.CreateCommandDefinition(prototype); return result; }
/// <summary> /// The constructor for PrimitiveType, it takes in a CLR type containing the identity information /// </summary> /// <param name="clrType">The CLR type object for this primitive type</param> /// <param name="baseType">The base type for this primitive type</param> /// <param name="providerManifest">The ProviderManifest of the provider of this type</param> internal PrimitiveType(Type clrType, PrimitiveType baseType, DbProviderManifest providerManifest) : this(EntityUtil.GenericCheckArgumentNull(clrType, "clrType").Name, clrType.Namespace, DataSpace.OSpace, baseType, providerManifest) { Debug.Assert(clrType == ClrEquivalentType, "not equivalent to ClrEquivalentType"); }
/// <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 DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) { var wrapperManifest = (DbProviderManifestWrapper)providerManifest; var createDbCommandDefinitionFunction = this.GetCreateDbCommandDefinitionFunction(wrapperManifest.WrappedProviderManifestInvariantName); DbCommandDefinition definition = createDbCommandDefinitionFunction(wrapperManifest.WrappedProviderManifest, commandTree); return this.CreateCommandDefinitionWrapper(definition, commandTree); }
/// <summary> /// Initializes a new instance of the DbProviderManifestWrapper class. /// </summary> /// <param name="wrapperProviderInvariantName">Wrapper provider invariant name.</param> /// <param name="providerInvariantName">Provider invariant name.</param> /// <param name="wrappedProviderManifest">The wrapped provider manifest.</param> public DbProviderManifestWrapper( string wrapperProviderInvariantName, string providerInvariantName, DbProviderManifest wrappedProviderManifest) { this.wrapperProviderInvariantName = wrapperProviderInvariantName; this.providerInvariantName = providerInvariantName; this.wrappedProviderManifest = wrappedProviderManifest; }
protected override DbCommandDefinition CreateDbCommandDefinition( DbProviderManifest providerManifest, DbCommandTree commandTree) { if (commandTree == null) throw new ArgumentNullException("commandTree"); SqlGenerator generator = null; if (commandTree is DbQueryCommandTree) generator = new SelectGenerator(); else if (commandTree is DbInsertCommandTree) generator = new InsertGenerator(); else if (commandTree is DbUpdateCommandTree) generator = new UpdateGenerator(); else if (commandTree is DbDeleteCommandTree) generator = new DeleteGenerator(); else if (commandTree is DbFunctionCommandTree) generator = new FunctionGenerator(); string sql = generator.GenerateSQL(commandTree); EFMySqlCommand cmd = new EFMySqlCommand(); cmd.CommandText = sql; if (generator is FunctionGenerator) cmd.CommandType = (generator as FunctionGenerator).CommandType; SetExpectedTypes(commandTree, cmd); EdmFunction function = null; if (commandTree is DbFunctionCommandTree) function = (commandTree as DbFunctionCommandTree).EdmFunction; // Now make sure we populate the command's parameters from the CQT's parameters: foreach (KeyValuePair<string, TypeUsage> queryParameter in commandTree.Parameters) { DbParameter parameter = cmd.CreateParameter(); parameter.ParameterName = queryParameter.Key; parameter.Direction = ParameterDirection.Input; parameter.DbType = Metadata.GetDbType(queryParameter.Value); FunctionParameter funcParam; if (function != null && function.Parameters.TryGetValue(queryParameter.Key, false, out funcParam)) { parameter.ParameterName = funcParam.Name; parameter.Direction = Metadata.ModeToDirection(funcParam.Mode); parameter.DbType = Metadata.GetDbType(funcParam.TypeUsage); } cmd.Parameters.Add(parameter); } // Now add parameters added as part of SQL gen foreach (DbParameter p in generator.Parameters) cmd.Parameters.Add(p); return CreateCommandDefinition(cmd); }
public LegacyDbProviderManifestWrapper(Legacy.DbProviderManifest wrappedProviderManifest) { Debug.Assert(wrappedProviderManifest != null, "wrappedProviderManifest != null"); _wrappedProviderManifest = wrappedProviderManifest; _legacyStoreTypes = _wrappedProviderManifest.GetStoreTypes().ToArray(); _storeTypes = new ReadOnlyCollection <PrimitiveType>( _legacyStoreTypes.Select(t => ConvertFromLegacyStoreEdmType(t, this)).ToList()); }
public LegacyDbProviderManifestWrapper(Legacy.DbProviderManifest wrappedProviderManifest) { Debug.Assert(wrappedProviderManifest != null, "wrappedProviderManifest != null"); _wrappedProviderManifest = wrappedProviderManifest; _legacyStoreTypes = _wrappedProviderManifest.GetStoreTypes().ToArray(); _storeTypes = new ReadOnlyCollection<PrimitiveType>( _legacyStoreTypes.Select(t => ConvertFromLegacyStoreEdmType(t, this)).ToList()); }
// used by EntityStoreSchemaGenerator to start with an empty (primitive types only) StoreItemCollection and // add types discovered from the database internal StoreItemCollection(DbProviderFactory factory, DbProviderManifest manifest, string providerManifestToken) : base(DataSpace.SSpace) { Debug.Assert(factory != null, "factory is null"); Debug.Assert(manifest != null, "manifest is null"); _providerFactory = factory; _providerManifest = manifest; _providerManifestToken = providerManifestToken; _cachedCTypeFunction = new Memoizer<EdmFunction, EdmFunction>(ConvertFunctionSignatureToCType, null); LoadProviderManifest(_providerManifest, true /*checkForSystemNamespace*/); }
public override IEnumerable<MigrationStatement> Generate(IEnumerable<MigrationOperation> migrationOperations, string providerManifestToken) { List<MigrationStatement> stmts = new List<MigrationStatement>(); MySqlConnection con = new MySqlConnection(); providerManifest = DbProviderServices.GetProviderServices(con).GetProviderManifest(providerManifestToken); foreach (MigrationOperation op in migrationOperations) { OpDispatcher opdis = dispatcher[op.GetType().Name]; stmts.Add(opdis(op)); } return stmts; }
public static DbProviderInfo GetProviderInfo( this DbConnection connection, out DbProviderManifest providerManifest) { //Contract.Requires(connection != null); var providerServices = DbProviderServices.GetProviderServices(connection); var providerManifestToken = providerServices.GetProviderManifestTokenChecked(connection); var providerInfo = new DbProviderInfo(connection.GetProviderInvariantName(), providerManifestToken); providerManifest = providerServices.GetProviderManifest(providerManifestToken); return providerInfo; }
/// <summary> /// The constructor for PrimitiveType. It takes the required information to identify this type. /// </summary> /// <param name="name">The name of this type</param> /// <param name="namespaceName">The namespace name of this type</param> /// <param name="version">The version of this type</param> /// <param name="dataSpace">dataSpace in which this primitive type belongs to</param> /// <param name="baseType">The primitive type that this type is derived from</param> /// <param name="providerManifest">The ProviderManifest of the provider of this type</param> /// <exception cref="System.ArgumentNullException">Thrown if name, namespaceName, version, baseType or providerManifest arguments are null</exception> internal PrimitiveType(string name, string namespaceName, DataSpace dataSpace, PrimitiveType baseType, DbProviderManifest providerManifest) : base(name, namespaceName, dataSpace) { EntityUtil.GenericCheckArgumentNull(baseType, "baseType"); EntityUtil.GenericCheckArgumentNull(providerManifest, "providerManifest"); this.BaseType = baseType; Initialize(this, baseType.PrimitiveTypeKind, false, // isDefault providerManifest); }
internal override void Configure( IEnumerable<Tuple<DbEdmPropertyMapping, DbTableMetadata>> propertyMappings, DbProviderManifest providerManifest, bool allowOverride = false) { base.Configure(propertyMappings, providerManifest, allowOverride); propertyMappings .Each( pm => { if (IsRowVersion != null) { pm.Item1.Column.Facets.MaxLength = null; } }); }
/// <summary> /// Converts a set of migration operations into Microsoft SQL Server specific SQL. /// </summary> /// <param name = "migrationOperations">The operations to be converted.</param> /// <param name = "providerManifestToken">Token representing the version of SQL Server being targeted (i.e. "2005", "2008").</param> /// <returns>A list of SQL statements to be executed to perform the migration operations.</returns> public override IEnumerable<MigrationStatement> Generate( IEnumerable<MigrationOperation> migrationOperations, string providerManifestToken) { _statements = new List<MigrationStatement>(); _generatedSchemas = new HashSet<string>(); _variableCounter = 0; using (var connection = CreateConnection()) { _providerManifest = DbProviderServices.GetProviderServices(connection) .GetProviderManifest(providerManifestToken); } migrationOperations.Each<dynamic>(o => Generate(o)); return _statements; }
/// <summary> /// Create a Command Definition object given a command tree. /// </summary> /// <param name="commandTree">command tree for the statement</param> /// <returns>an exectable command definition object</returns> /// <remarks> /// This method simply delegates to the provider's implementation of CreateDbCommandDefinition. /// </remarks> public DbCommandDefinition CreateCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) { try { return CreateDbCommandDefinition(providerManifest, commandTree); } catch (ProviderIncompatibleException) { throw; } catch (Exception e) { if (EntityUtil.IsCatchableExceptionType(e)) { throw EntityUtil.ProviderIncompatible(Strings.ProviderDidNotCreateACommandDefinition, e); } throw; } }
/// <summary> /// Create a Command Definition object given a command tree. /// </summary> /// <param name="commandTree">command tree for the statement</param> /// <returns>an executable command definition object</returns> /// <remarks> /// This method simply delegates to the provider's implementation of CreateDbCommandDefinition. /// </remarks> public DbCommandDefinition CreateCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) { //Contract.Requires(providerManifest != null); //Contract.Requires(commandTree != null); try { return CreateDbCommandDefinition(providerManifest, commandTree); } catch (ProviderIncompatibleException) { throw; } catch (Exception e) { if (e.IsCatchableExceptionType()) { throw new ProviderIncompatibleException(Strings.ProviderDidNotCreateACommandDefinition, e); } throw; } }
internal static List<EdmSchemaError> LoadItems(DbProviderManifest manifest, IList<Schema> somSchemas, ItemCollection itemCollection) { List<EdmSchemaError> errors = new List<EdmSchemaError>(); // Convert the schema, if model schema, then we use the EDM provider manifest, otherwise use the // store provider manifest IEnumerable<GlobalItem> newGlobalItems = LoadSomSchema(somSchemas, manifest, itemCollection); List<String> tempCTypeFunctionIdentity = new List<string>(); // No errors, so go ahead and add the types and make them readonly foreach (GlobalItem globalItem in newGlobalItems) { // If multiple function parameter and return types expressed in SSpace map to the same // CSpace type (e.g., SqlServer.decimal and SqlServer.numeric both map to Edm.Decimal), // we need to guard against attempts to insert duplicate functions into the collection. // if (globalItem.BuiltInTypeKind == BuiltInTypeKind.EdmFunction && globalItem.DataSpace == DataSpace.SSpace) { EdmFunction function = (EdmFunction)globalItem; StringBuilder sb = new StringBuilder(); EdmFunction.BuildIdentity( sb, function.FullName, function.Parameters, // convert function parameters to C-side types (param) => MetadataHelper.ConvertStoreTypeUsageToEdmTypeUsage(param.TypeUsage), (param) => param.Mode); string cTypeFunctionIdentity = sb.ToString(); // Validate identity if (tempCTypeFunctionIdentity.Contains(cTypeFunctionIdentity)) { errors.Add( new EdmSchemaError( Strings.DuplicatedFunctionoverloads(function.FullName, cTypeFunctionIdentity.Substring(function.FullName.Length)).Trim()/*parameters*/, (int)ErrorCode.DuplicatedFunctionoverloads, EdmSchemaErrorSeverity.Error)); continue; } tempCTypeFunctionIdentity.Add(cTypeFunctionIdentity); } globalItem.SetReadOnly(); itemCollection.AddInternal(globalItem); } return errors; }
/// <summary> /// Load metadata from a SOM schema directly /// </summary> /// <param name="somSchema">The SOM schema to load from</param> /// <param name="providerManifest">The provider manifest used for loading the type</param> /// <param name="itemCollection">item collection in which primitive types are present</param> /// <returns>The newly created items</returns> internal static IEnumerable<GlobalItem> LoadSomSchema(IList<Schema> somSchemas, DbProviderManifest providerManifest, ItemCollection itemCollection) { IEnumerable<GlobalItem> newGlobalItems = Converter.ConvertSchema(somSchemas, providerManifest, itemCollection); return newGlobalItems; }
internal static bool IsSystemNamespace(DbProviderManifest manifest, string namespaceName) { if (manifest == MetadataItem.EdmProviderManifest) { return (namespaceName == EdmConstants.TransientNamespace || namespaceName == EdmConstants.EdmNamespace || namespaceName == EdmConstants.ClrPrimitiveTypeNamespace); } else { return (namespaceName == EdmConstants.TransientNamespace || namespaceName == EdmConstants.EdmNamespace || namespaceName == EdmConstants.ClrPrimitiveTypeNamespace || (manifest != null && namespaceName == manifest.NamespaceName)); } }
/// <summary> /// Load stuff from xml readers - this now includes XmlReader instances created over embedded /// resources. See the remarks section below for some useful information. /// </summary> /// <param name="xmlReaders">A list of XmlReader instances</param> /// <param name="dataModelOption">whether this is a entity data model or provider data model</param> /// <param name="providerManifest">provider manifest from which the primitive type definition comes from</param> /// <param name="itemCollection">item collection to add the item after loading</param> /// <param name="computeFilePaths">Indicates whether the method should bother with the file paths; see remarks below</param> /// <remarks> /// In order to accommodate XmlReaders over artifacts embedded as resources in assemblies, the /// notion of a filepath had to be abstracted into a URI. In reality, however, a res:// URI that /// points to an embedded resource does not constitute a valid URI (i.e., one that can be parsed /// by the System.Uri class in the .NET framework). In such cases, we need to supply a list of /// "filepaths" (which includes res:// URIs), instead of having this method create the collection. /// This distinction is made by setting the 'computeFilePaths' flags appropriately. /// </remarks> internal static IList<EdmSchemaError> LoadItems(IEnumerable<XmlReader> xmlReaders, IEnumerable<string> sourceFilePaths, SchemaDataModelOption dataModelOption, DbProviderManifest providerManifest, ItemCollection itemCollection, bool throwOnError) { IList<Schema> schemaCollection = null; // Parse and validate all the schemas - since we support using now, // we need to parse them as a group var errorCollection = SchemaManager.ParseAndValidate(xmlReaders, sourceFilePaths, dataModelOption, providerManifest, out schemaCollection); // Try to initialize the metadata if there are no errors if (MetadataHelper.CheckIfAllErrorsAreWarnings(errorCollection)) { List<EdmSchemaError> errors = LoadItems(providerManifest, schemaCollection, itemCollection); foreach (var error in errors) { errorCollection.Add(error); } } if (!MetadataHelper.CheckIfAllErrorsAreWarnings(errorCollection) && throwOnError) { //Future Enhancement: if there is an error, we throw exception with error and warnings. //Otherwise the user has no clue to know about warnings. throw EntityUtil.InvalidSchemaEncountered(Helper.CombineErrorMessage(errorCollection)); } return errorCollection; }
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest manifest, DbCommandTree commandTree) { DbCommand prototype = CreateCommand(manifest, commandTree); DbCommandDefinition result = this.CreateCommandDefinition(prototype); return result; }
/// <summary> /// Create a SampleCommand object, given the provider manifest and command tree /// </summary> private DbCommand CreateCommand(DbProviderManifest manifest, DbCommandTree commandTree) { if (manifest == null) throw new ArgumentNullException("manifest"); if (commandTree == null) throw new ArgumentNullException("commandTree"); SampleProviderManifest sampleManifest = (manifest as SampleProviderManifest); if (sampleManifest == null) { throw new ArgumentException("The provider manifest given is not of type 'SampleProviderManifest'."); } StoreVersion version = sampleManifest.Version; SampleCommand command = new SampleCommand(); List<DbParameter> parameters; CommandType commandType; command.CommandText = SqlGenerator.GenerateSql(commandTree, version, out parameters, out commandType); command.CommandType = commandType; if (command.CommandType == CommandType.Text) { command.CommandText += Environment.NewLine + Environment.NewLine + "-- provider: " + this.GetType().Assembly.FullName; } // Get the function (if any) implemented by the command tree since this influences our interpretation of parameters EdmFunction function = null; if (commandTree is DbFunctionCommandTree) { function = ((DbFunctionCommandTree)commandTree).EdmFunction; } // Now make sure we populate the command's parameters from the CQT's parameters: foreach (KeyValuePair<string, TypeUsage> queryParameter in commandTree.Parameters) { SqlParameter parameter; // Use the corresponding function parameter TypeUsage where available (currently, the SSDL facets and // type trump user-defined facets and type in the EntityCommand). FunctionParameter functionParameter; if (null != function && function.Parameters.TryGetValue(queryParameter.Key, false, out functionParameter)) { parameter = CreateSqlParameter(functionParameter.Name, functionParameter.TypeUsage, functionParameter.Mode, DBNull.Value); } else { parameter = CreateSqlParameter(queryParameter.Key, queryParameter.Value, ParameterMode.In, DBNull.Value); } command.Parameters.Add(parameter); } // Now add parameters added as part of SQL gen (note: this feature is only safe for DML SQL gen which // does not support user parameters, where there is no risk of name collision) if (null != parameters && 0 < parameters.Count) { if (!(commandTree is DbInsertCommandTree) && !(commandTree is DbUpdateCommandTree) && !(commandTree is DbDeleteCommandTree)) { throw new InvalidOperationException("SqlGenParametersNotPermitted"); } foreach (DbParameter parameter in parameters) { command.Parameters.Add(parameter); } } return command; }
public static IList<EdmSchemaError> ParseAndValidate(IEnumerable<XmlReader> xmlReaders, IEnumerable<string> sourceFilePaths, SchemaDataModelOption dataModel, DbProviderManifest providerManifest, out IList<Schema> schemaCollection) { return ParseAndValidate(xmlReaders, sourceFilePaths, dataModel, NoOpAttributeValueNotification, NoOpAttributeValueNotification, delegate(Action<string, ErrorCode, EdmSchemaErrorSeverity> addError) { return providerManifest == null ? MetadataItem.EdmProviderManifest : providerManifest; }, out schemaCollection); }
protected abstract DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree);
private IList<EdmSchemaError> Init(IEnumerable<XmlReader> xmlReaders, IEnumerable<string> filePaths, bool throwOnError, out DbProviderManifest providerManifest, out DbProviderFactory providerFactory, out string providerManifestToken, out Memoizer<EdmFunction, EdmFunction> cachedCTypeFunction) { EntityUtil.CheckArgumentNull(xmlReaders, "xmlReaders"); // 'filePaths' can be null cachedCTypeFunction = new Memoizer<EdmFunction, EdmFunction>(ConvertFunctionSignatureToCType, null); Loader loader = new Loader(xmlReaders, filePaths, throwOnError); providerFactory = loader.ProviderFactory; providerManifest = loader.ProviderManifest; providerManifestToken = loader.ProviderManifestToken; // load the items into the colleciton if (!loader.HasNonWarningErrors) { LoadProviderManifest(loader.ProviderManifest, true /* check for system namespace */); List<EdmSchemaError> errorList = EdmItemCollection.LoadItems(_providerManifest, loader.Schemas, this); foreach (var error in errorList) { loader.Errors.Add(error); } if (throwOnError && errorList.Count != 0) loader.ThrowOnNonWarningErrors(); } return loader.Errors; }
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) { return new GlimpseProfileDbCommandDefinition(InnerProviderServices.CreateCommandDefinition(commandTree), Stats); }
/// <summary> /// checks if the schemaKey refers to the provider manifest schema key /// and if true, loads the provider manifest /// </summary> /// <param name="connection">The connection where the store manifest is loaded from</param> /// <param name="checkForSystemNamespace">Check for System namespace</param> /// <returns>The provider manifest object that was loaded</returns> private void LoadProviderManifest(DbProviderManifest storeManifest, bool checkForSystemNamespace) { foreach (PrimitiveType primitiveType in storeManifest.GetStoreTypes()) { //Add it to the collection and the primitive type maps this.AddInternal(primitiveType); _primitiveTypeMaps.Add(primitiveType); } foreach (EdmFunction function in storeManifest.GetStoreFunctions()) { AddInternal(function); } }