本文整理汇总了C#中DbProviderManifest类的典型用法代码示例。如果您正苦于以下问题:C# DbProviderManifest类的具体用法?C# DbProviderManifest怎么用?C# DbProviderManifest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DbProviderManifest类属于命名空间,在下文中一共展示了DbProviderManifest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDbCommandDefinition
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
{
Check.NotNull(providerManifest, "providerManifest");
Check.NotNull(commandTree, "commandTree");
return CreateDbCommandDefinition(providerManifest, commandTree, new DbInterceptionContext());
}
示例2: LegacyDbProviderManifestWrapperTests
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);
}
}
示例3: CreateProviderManifest
/// <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(
this.ProviderInvariantName,
providerInvariantName,
providerManifest);
}
示例4: CreateDbCommandDefinition
/// <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 executable command definition object </returns>
/// <exception cref="ArgumentNullException">connection and commandTree arguments must not be null</exception>
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
{
Check.NotNull(providerManifest, "providerManifest");
Check.NotNull(commandTree, "commandTree");
var storeMetadata = (StoreItemCollection)commandTree.MetadataWorkspace.GetItemCollection(DataSpace.SSpace);
return CreateCommandDefinition(storeMetadata.StoreProviderFactory, commandTree);
}
示例5: CreateDbCommandDefinition
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
{
return new CachingCommandDefinition(
_providerServices.CreateCommandDefinition(providerManifest, commandTree),
new CommandTreeFacts(commandTree),
_cacheTransactionHandler,
_cachingPolicy);
}
示例6: CreateDbCommandDefinition
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?");
var prototype = CreateCommand(providerManifest, commandTree);
var result = CreateCommandDefinition(prototype);
return result;
}
示例7: CreateDbCommandDefinition
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);
}
示例8: CreateDbCommandDefinition
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
{
var entityCommandDefinition = EntityCommandDefinition;
if (entityCommandDefinition == null)
{
entityCommandDefinition = new Mock<EntityCommandDefinition>(MockBehavior.Loose, null, null, null).Object;
}
return entityCommandDefinition;
}
示例9: StoreItemCollection
// 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);
}
示例10: GetProviderInfo
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;
}
示例11: StoreItemCollection
// 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 providerInvariantName, string providerManifestToken)
: base(DataSpace.SSpace)
{
DebugCheck.NotNull(factory);
DebugCheck.NotNull(manifest);
_providerFactory = factory;
_providerManifest = manifest;
_providerInvariantName = providerInvariantName;
_providerManifestToken = providerManifestToken;
_cachedCTypeFunction = new Memoizer<EdmFunction, EdmFunction>(ConvertFunctionSignatureToCType, null);
LoadProviderManifest(_providerManifest);
}
示例12: GetProviderInfo
public static DbProviderInfo GetProviderInfo(
this DbConnection connection, out DbProviderManifest providerManifest)
{
DebugCheck.NotNull(connection);
var providerManifestToken = DbConfiguration
.GetService<IManifestTokenService>()
.GetProviderManifestToken(connection);
var providerInfo = new DbProviderInfo(connection.GetProviderInvariantName(), providerManifestToken);
providerManifest = DbProviderServices.GetProviderServices(connection).GetProviderManifest(providerManifestToken);
return providerInfo;
}
示例13: CreateCommandDefinition
/// <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;
}
}
示例14: CreateDbCommandDefinition
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
{
Debug.Assert(providerManifest != null, "providerManifest != null");
Debug.Assert(
providerManifest is LegacyDbProviderManifestWrapper, "providerManifest expected to be LegacyDbProviderManifestWrapper");
Debug.Assert(commandTree != null, "commandTree != null");
Debug.Assert(commandTree is DbQueryCommandTree, "Only query trees are supported");
Debug.Assert(commandTree.DataSpace == DataSpace.SSpace, "SSpace tree expected");
try
{
var legacyMetadata = commandTree.MetadataWorkspace.ToLegacyMetadataWorkspace();
var legacyQuery =
((DbQueryCommandTree)commandTree).Query.Accept(
new LegacyDbExpressionConverter(
(LegacyMetadata.StoreItemCollection)
legacyMetadata.GetItemCollection(LegacyMetadata.DataSpace.SSpace)));
var legacyCommandTree =
(LegacyCommandTrees.DbCommandTree)LegacyDbQueryCommandTreeCtor.Invoke(
new object[]
{
legacyMetadata,
LegacyMetadata.DataSpace.SSpace,
legacyQuery
});
return new LegacyDbCommandDefinitionWrapper(
_wrappedProviderServices.CreateCommandDefinition(
((LegacyDbProviderManifestWrapper)providerManifest).WrappedManifest,
legacyCommandTree));
}
catch (SystemData.ProviderIncompatibleException exception)
{
throw new ProviderIncompatibleException(exception.Message, exception.InnerException);
}
}
示例15: CreateDbCommandDefinition
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
{
return CreateCommandDefinition(CreateDbCommand(((NpgsqlProviderManifest)providerManifest).Version, commandTree));
}