Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into async

Conflicts:
	.gitignore
	test/EntityFramework/UnitTests/SqlServer/SqlSpatialDataReaderTests.cs
	test/EntityFramework/UnitTests/UnitTests.csproj
  • Loading branch information...
commit f0ce29aaa16e256bb0b51914d843ae2a301b69ca 2 parents 3296a2d + bb0ffeb
@AndriySvyryd AndriySvyryd authored
Showing with 6,277 additions and 5,262 deletions.
  1. +1 −0  .gitignore
  2. +1 −0  src/EntityFramework.SqlServer/EntityFramework.SqlServer.csproj
  3. +6 −30 src/EntityFramework.SqlServer/SqlProviderServices.cs
  4. +12 −9 src/EntityFramework.SqlServer/SqlSpatialDataReader.cs
  5. +40 −24 src/EntityFramework.SqlServer/SqlSpatialServices.cs
  6. +3 −107 src/EntityFramework.SqlServer/SqlTypesAssembly.cs
  7. +137 −0 src/EntityFramework.SqlServer/SqlTypesAssemblyLoader.cs
  8. +1 −1  src/EntityFramework.SqlServerCompact/SqlCeProviderServices.cs
  9. +13 −5 src/EntityFramework/Config/AppConfigDependencyResolver.cs
  10. +2 −2 src/EntityFramework/Config/CompositeResolver`.cs
  11. +24 −9 src/EntityFramework/Config/DbConfiguration.cs
  12. +7 −26 src/EntityFramework/Config/DbConfigurationFinder.cs
  13. +1 −1  src/EntityFramework/Config/DbConfigurationLoader.cs
  14. +16 −10 src/EntityFramework/Config/DbConfigurationManager.cs
  15. +1 −1  src/EntityFramework/Config/DbConfigurationProxy.cs
  16. +1 −1  src/EntityFramework/Config/DbNullConfiguration.cs
  17. +27 −0 src/EntityFramework/Config/DefaultProviderServicesResolver.cs
  18. +0 −2  src/EntityFramework/Config/IDbDependencyResolver.cs
  19. +1 −1  src/EntityFramework/Config/IDbDependencyResolverExtensions.cs
  20. +39 −0 src/EntityFramework/Config/MigrationsConfigurationResolver.cs
  21. +1 −1  src/EntityFramework/Config/ProviderServicesFactory.cs
  22. +1 −1  src/EntityFramework/Config/ResolverChain.cs
  23. +22 −26 src/EntityFramework/Config/RootDependencyResolver.cs
  24. +1 −1  src/EntityFramework/Config/SingletonDependencyResolver.cs
  25. +22 −22 src/EntityFramework/Core/Common/CommandTrees/DefaultExpressionVisitor.cs
  26. +51 −51 src/EntityFramework/Core/Common/CommandTrees/ExpressionBuilder/Internal/ArgumentValidation.cs
  27. +48 −48 src/EntityFramework/Core/Common/CommandTrees/Internal/Patterns.cs
  28. +47 −15 src/EntityFramework/Core/Common/DbProviderServices.cs
  29. +775 −775 src/EntityFramework/Core/Common/EntitySql/CqlLexer.cs
  30. +6 −6 src/EntityFramework/Core/Common/EntitySql/CqlLexerHelpers.cs
  31. +1,567 −1,567 src/EntityFramework/Core/Common/EntitySql/CqlParser.cs
  32. +11 −11 src/EntityFramework/Core/Common/EntitySql/CqlQuery.cs
  33. +571 −571 src/EntityFramework/Core/Common/EntitySql/SemanticAnalyzer.cs
  34. +3 −16 src/EntityFramework/Core/Common/EntityUtil.cs
  35. +45 −45 src/EntityFramework/Core/Common/internal/DbTypeMap.cs
  36. +9 −9 src/EntityFramework/Core/Common/internal/materialization/recordstatescratchpad.cs
  37. +6 −6 src/EntityFramework/Core/EntityClient/EntityConnectionStringBuilder.cs
  38. +1 −1  src/EntityFramework/Core/EntityClient/Internal/EntityProviderServices.cs
  39. +3 −3 src/EntityFramework/Core/EntityKey.cs
  40. +20 −20 src/EntityFramework/Core/EntityModel/SchemaObjectModel/XmlSchemaResource.cs
  41. +12 −12 src/EntityFramework/Core/Mapping/FunctionImportMappingComposable.cs
  42. +3 −3 src/EntityFramework/Core/Mapping/StorageMappingItemCollection.cs
  43. +42 −42 src/EntityFramework/Core/Mapping/StorageMappingItemLoader.cs
  44. +19 −19 src/EntityFramework/Core/Mapping/Update/Internal/FunctionMappingTranslator.cs
  45. +3 −3 src/EntityFramework/Core/Mapping/Update/Internal/KeyManager.cs
  46. +9 −9 src/EntityFramework/Core/Mapping/Update/Internal/Propagator.JoinPropagator.cs
  47. +1 −1  src/EntityFramework/Core/Metadata/Edm/ItemCollection.cs
  48. +74 −74 src/EntityFramework/Core/Metadata/Edm/Provider/EdmProviderManifest.cs
  49. +3 −3 src/EntityFramework/Core/Metadata/Edm/RelationshipEndMember.cs
  50. +10 −10 src/EntityFramework/Core/Metadata/Edm/TypeUsage.cs
  51. +1 −1  src/EntityFramework/Core/Metadata/ObjectItemCollection.cs
  52. +12 −11 src/EntityFramework/Core/Metadata/ObjectLayer/ObjectItemAttributeAssemblyLoader.cs
  53. +8 −7 src/EntityFramework/Core/Metadata/ObjectLayer/ObjectItemConventionAssemblyLoader.cs
  54. +31 −31 src/EntityFramework/Core/Objects/ELinq/Funcletizer.cs
  55. +78 −78 src/EntityFramework/Core/Objects/ELinq/MethodCallTranslator.cs
  56. +7 −7 src/EntityFramework/Core/Objects/Internal/DataContractImplementor.cs
  57. +32 −32 src/EntityFramework/Core/Objects/Internal/EntityProxyFactory.cs
  58. +12 −12 src/EntityFramework/Core/Objects/Internal/EntityProxyTypeInfo.cs
  59. +20 −20 src/EntityFramework/Core/Objects/Internal/PocoPropertyAccessorStrategy.cs
  60. +3 −3 src/EntityFramework/Core/Objects/ObjectStateManager.cs
  61. +13 −13 src/EntityFramework/Core/Query/PlanCompiler/ApplyOpRules.cs
  62. +3 −3 src/EntityFramework/Core/Query/PlanCompiler/ConstrainedSortOpRules.cs
  63. +3 −3 src/EntityFramework/Core/Query/PlanCompiler/DistinctOpRules.cs
  64. +14 −14 src/EntityFramework/Core/Query/PlanCompiler/FilterOpRules.cs
  65. +5 −5 src/EntityFramework/Core/Query/PlanCompiler/GroupByOpRules.cs
  66. +15 −15 src/EntityFramework/Core/Query/PlanCompiler/JoinOpRules.cs
  67. +3 −3 src/EntityFramework/Core/Query/PlanCompiler/PrimitiveTypeVarInfo.cs
  68. +6 −6 src/EntityFramework/Core/Query/PlanCompiler/ProjectOpRules.cs
  69. +16 −16 src/EntityFramework/Core/Query/PlanCompiler/ScalarOpRules.cs
  70. +5 −5 src/EntityFramework/Core/Query/PlanCompiler/SetOpRules.cs
  71. +4 −4 src/EntityFramework/Core/Query/PlanCompiler/SingleRowOpRules.cs
  72. +3 −3 src/EntityFramework/Core/Query/PlanCompiler/SortOpRules.cs
  73. +11 −11 src/EntityFramework/Core/Query/PlanCompiler/Validator.cs
  74. +3 −1 src/EntityFramework/Database.cs
  75. +33 −33 src/EntityFramework/Edm/EdmPrimitiveType.cs
  76. +30 −30 src/EntityFramework/Edm/Serialization/Xml/Internal/Csdl/EdmModelCsdlSchemaWriter.cs
  77. +4 −4 src/EntityFramework/Edm/Serialization/Xml/Internal/Ssdl/DbModelSsdlHelper.cs
  78. +4 −0 src/EntityFramework/EntityFramework.csproj
  79. +2 −2 src/EntityFramework/Infrastructure/DbContextInfo.cs
  80. +8 −8 src/EntityFramework/Infrastructure/IDbModelCacheKey.cs
  81. +7 −7 src/EntityFramework/Infrastructure/IDbModelCacheKeyFactory.cs
  82. +16 −0 src/EntityFramework/Internal/ConfigFile/MigrationSqlGeneratorElement.cs
  83. +8 −0 src/EntityFramework/Internal/ConfigFile/ProviderElement.cs
  84. +20 −3 src/EntityFramework/Internal/DatabaseCreator.cs
  85. +6 −6 src/EntityFramework/Internal/DbSetDiscoveryService.cs
  86. +59 −59 src/EntityFramework/Internal/DefaultModelCacheKey.cs
  87. +25 −25 src/EntityFramework/Internal/DefaultModelCacheKeyFactory.cs
  88. +13 −13 src/EntityFramework/Internal/EntityEntries/InternalNestedPropertyEntry.cs
  89. +2 −1  src/EntityFramework/Internal/InternalContext.cs
  90. +3 −3 src/EntityFramework/Internal/LazyInternalConnection.cs
  91. +2 −3 src/EntityFramework/Internal/LazyInternalContext.cs
  92. +3 −3 src/EntityFramework/Internal/ModelHashCalculator.cs
  93. +41 −5 src/EntityFramework/Internal/ProviderConfig.cs
  94. +3 −3 src/EntityFramework/MigrateDatabaseToLatestVersion`.cs
  95. +14 −14 src/EntityFramework/Migrations/Builders/ColumnBuilder.cs
  96. +13 −13 src/EntityFramework/Migrations/Builders/TableBuilder.cs
  97. +37 −37 src/EntityFramework/Migrations/DbMigration.cs
  98. +13 −8 src/EntityFramework/Migrations/DbMigrationsConfiguration.cs
  99. +13 −11 src/EntityFramework/Migrations/DbMigrator.cs
  100. +6 −6 src/EntityFramework/Migrations/Design/CSharpMigrationCodeGenerator.cs
  101. +3 −3 src/EntityFramework/Migrations/Design/MigrationCodeGenerator.cs
  102. +45 −70 src/EntityFramework/Migrations/Design/ToolingFacade.cs
  103. +6 −6 src/EntityFramework/Migrations/Design/VisualBasicMigrationCodeGenerator.cs
  104. +12 −12 src/EntityFramework/Migrations/Edm/EdmXNames.cs
  105. +4 −4 src/EntityFramework/Migrations/History/HistoryRepository.cs
  106. +66 −66 src/EntityFramework/Migrations/Infrastructure/EdmModelDiffer.cs
  107. +8 −8 src/EntityFramework/Migrations/Model/AddForeignKeyOperation.cs
  108. +4 −4 src/EntityFramework/Migrations/Model/AddPrimaryKeyOperation.cs
  109. +17 −17 src/EntityFramework/Migrations/Model/ColumnModel.cs
  110. +4 −4 src/EntityFramework/Migrations/Model/CreateIndexOperation.cs
  111. +3 −3 src/EntityFramework/Migrations/Model/DropForeignKeyOperation.cs
  112. +4 −4 src/EntityFramework/Migrations/Model/DropPrimaryKeyOperation.cs
  113. +25 −25 src/EntityFramework/ModelConfiguration/Configuration/Mapping/EntityMappingTransformer.cs
  114. +5 −5 src/EntityFramework/ModelConfiguration/Configuration/Mapping/NotNullConditionConfiguration.cs
  115. +24 −24 src/EntityFramework/ModelConfiguration/Configuration/Mapping/Services/EntityMappingService.cs
  116. +11 −11 src/EntityFramework/ModelConfiguration/Configuration/ModelConfiguration.cs
  117. +7 −7 ...EntityFramework/ModelConfiguration/Configuration/Properties/Navigation/ForeignKeyConstraintConfiguration.cs
  118. +3 −3 src/EntityFramework/ModelConfiguration/Configuration/Properties/Primitive/PrimitivePropertyConfiguration.cs
  119. +4 −4 src/EntityFramework/ModelConfiguration/Configuration/Types/EntityTypeConfiguration.cs
  120. +4 −4 src/EntityFramework/ModelConfiguration/Conventions/Edm/AssociationInverseDiscoveryConvention.cs
  121. +10 −10 src/EntityFramework/ModelConfiguration/Conventions/Edm/ComplexTypeDiscoveryConvention.cs
  122. +4 −4 src/EntityFramework/ModelConfiguration/Conventions/Edm/Db/ColumnOrderingConvention.cs
  123. +4 −4 src/EntityFramework/ModelConfiguration/Conventions/Edm/ForeignKeyDiscoveryConvention.cs
  124. +9 −9 src/EntityFramework/ModelConfiguration/Conventions/Edm/ForeignKeyNavigationPropertyAttributeConvention.cs
  125. +4 −4 src/EntityFramework/ModelConfiguration/Conventions/Edm/OneToOneConstraintIntroductionConvention.cs
  126. +41 −41 src/EntityFramework/ModelConfiguration/Conventions/Sets/V1ConventionSet.cs
  127. +5 −5 src/EntityFramework/ModelConfiguration/Design/EnglishPluralizationService.cs
  128. +3 −3 src/EntityFramework/ModelConfiguration/Edm/Common/DataModelAnnotationExtensions.cs
  129. +7 −7 src/EntityFramework/ModelConfiguration/Edm/Db/DbDatabaseMetadataExtensions.cs
  130. +9 −9 src/EntityFramework/ModelConfiguration/Edm/Db/DbTableColumnMetadataExtensions.cs
  131. +3 −3 src/EntityFramework/ModelConfiguration/Edm/Db/DbTableMetadataExtensions.cs
  132. +12 −12 src/EntityFramework/ModelConfiguration/Edm/Db/Mapping/DbDatabaseMappingExtensions.cs
  133. +3 −3 src/EntityFramework/ModelConfiguration/Edm/Db/Mapping/DbEntityTypeMappingExtensions.cs
  134. +3 −3 src/EntityFramework/ModelConfiguration/Edm/EdmComplexTypeExtensions.cs
  135. +8 −8 src/EntityFramework/ModelConfiguration/Edm/EdmEntityTypeExtensions.cs
  136. +4 −4 src/EntityFramework/ModelConfiguration/Edm/EdmEnumTypeExtensions.cs
  137. +22 −22 src/EntityFramework/ModelConfiguration/Edm/EdmModelExtensions.cs
  138. +11 −11 src/EntityFramework/ModelConfiguration/Edm/EdmPropertyExtensions.cs
  139. +17 −17 src/EntityFramework/ModelConfiguration/Edm/Services/AssociationTypeMappingGenerator.cs
  140. +7 −7 src/EntityFramework/ModelConfiguration/Edm/Services/EntityTypeMappingGenerator.cs
  141. +3 −3 src/EntityFramework/ModelConfiguration/EntityTypeConfiguration.cs
  142. +6 −6 src/EntityFramework/ModelConfiguration/Mappers/PropertyMapper.cs
  143. +4 −4 src/EntityFramework/ModelConfiguration/Mappers/TypeMapper.cs
  144. +39 −80 src/EntityFramework/Properties/Resources.cs
  145. +15 −22 src/EntityFramework/Properties/Resources.resx
  146. +10 −34 src/EntityFramework/Spatial/DbSpatialServices.cs
  147. +10 −10 src/EntityFramework/Spatial/DefaultSpatialServices.cs
  148. +48 −0 src/EntityFramework/Spatial/SpatialServicesLoader.cs
  149. +3 −3 src/EntityFramework/Utilities/DbContextExtensions.cs
  150. +0 −1  src/EntityFramework/Utilities/DbProviderFactoryExtensions.cs
  151. +3 −3 src/EntityFramework/Utilities/PropertyInfoExtensions.cs
  152. +44 −0 src/EntityFramework/Utilities/TypeExtensions.cs
  153. +5 −0 src/NuGet/EntityFramework.SqlServerCompact/Content/App.config.transform
  154. +5 −0 src/NuGet/EntityFramework.SqlServerCompact/Content/Web.config.transform
  155. +2 −2 src/NuGet/EntityFramework.SqlServerCompact/EntityFramework.SqlServerCompact.nuspec
  156. +1 −2  src/NuGet/EntityFramework/EntityFramework.nuspec
  157. +2 −0  src/NuGet/NuGet.proj
  158. +11 −1 src/PowerTools/CodeTemplates/ReverseEngineerCodeFirst/Entity.tt
  159. +27 −0 src/PowerTools/Handlers/OptimizeContextHandler.cs
  160. +1 −1  test/EntityFramework/DropAllDatabases.sql
  161. +1 −1  test/EntityFramework/FunctionalTests/CodeFirst/ConventionsScenarioTests.cs
  162. +1 −1  test/EntityFramework/FunctionalTests/CodeFirst/DataServicesTests.cs
  163. +1 −1  test/EntityFramework/FunctionalTests/Migrations/TestHelpers/DbTestCase.cs
  164. +18 −5 test/EntityFramework/FunctionalTests/Migrations/TestHelpers/TestDatabase.cs
  165. +1 −1  test/EntityFramework/FunctionalTests/ProductivityApi/ConnectionTests.cs
  166. +3 −3 test/EntityFramework/FunctionalTests/ProductivityApi/DatabaseInitializationTests.cs
  167. +6 −11 test/EntityFramework/FunctionalTests/ProductivityApi/DbConnectionFactoryTests.cs
  168. +13 −6 test/EntityFramework/FunctionalTests/TestHelpers/FunctionalTestBase.cs
  169. +3 −1 test/EntityFramework/UnitTests/App.config
  170. +137 −46 test/EntityFramework/UnitTests/AppConfigTests.cs
  171. +62 −5 test/EntityFramework/UnitTests/Config/AppConfigDependencyResolverTests.cs
  172. +0 −37 test/EntityFramework/UnitTests/Config/DbConfigurationFinderTests.cs
  173. +62 −6 test/EntityFramework/UnitTests/Config/DbConfigurationTests.cs
  174. +61 −0 test/EntityFramework/UnitTests/Config/DefaultProviderServicesResolverTests.cs
  175. +46 −0 test/EntityFramework/UnitTests/Config/MigrationsConfigurationResolverTests.cs
  176. +30 −41 test/EntityFramework/UnitTests/Config/RootDependencyResolverTests.cs
  177. +85 −1 test/EntityFramework/UnitTests/Core/Common/DbProviderServicesTests.cs
  178. +0 −145 test/EntityFramework/UnitTests/DatabaseInitializationTests.cs
  179. +18 −0 test/EntityFramework/UnitTests/Internal/ConfigFile/MigrationSqlGeneratorElementTests.cs
  180. +19 −7 test/EntityFramework/UnitTests/Internal/ConfigFile/ProviderElementTests.cs
  181. +188 −0 test/EntityFramework/UnitTests/Internal/DatabaseCreatorTests.cs
  182. +1 −1  test/EntityFramework/UnitTests/ModelHashCalculatorTests.cs
  183. +18 −0 test/EntityFramework/UnitTests/Spatial/DbSpatialServicesTests.cs
  184. +70 −0 test/EntityFramework/UnitTests/Spatial/SpatialServicesLoaderTests.cs
  185. +4 −4 test/EntityFramework/UnitTests/SqlServer/SqlSpatialDataReaderTests.cs
  186. +58 −4 test/EntityFramework/UnitTests/SqlServer/SqlSpatialServicesTests.cs
  187. +39 −0 test/EntityFramework/UnitTests/SqlServer/SqlTypesAssemblyLoaderTests.cs
  188. +16 −0 test/EntityFramework/UnitTests/TestHelpers/Fake/FakeSqlGenerator.cs
  189. +1 −1  test/EntityFramework/UnitTests/TestHelpers/Fake/FakeSqlProviderServices.cs
  190. +8 −0 test/EntityFramework/UnitTests/UnitTests.csproj
  191. +211 −91 test/EntityFramework/UnitTests/Utilities/TypeExtensionsTests.cs
View
1  .gitignore
@@ -16,6 +16,7 @@ TestResults
packages
EntityFramework.xml
EntityFramework.SqlServer.xml
+EntityFramework.SqlServerCompact.xml
*.BASE.*
*.REMOTE.*
*.LOCAL.*
View
1  src/EntityFramework.SqlServer/EntityFramework.SqlServer.csproj
@@ -139,6 +139,7 @@
<Compile Include="SqlDdlBuilder.cs" />
<Compile Include="SqlGen\BoolWrapper.cs" />
<Compile Include="SqlGen\DmlSqlGenerator.cs" />
+ <Compile Include="SqlTypesAssemblyLoader.cs" />
<Compile Include="SqlVersionUtils.cs" />
<Compile Include="Utilities\DbExpressionExtensions.cs" />
<Compile Include="Utilities\EdmFunctionExtensions.cs" />
View
36 src/EntityFramework.SqlServer/SqlProviderServices.cs
@@ -36,6 +36,8 @@ private SqlProviderServices()
/// </summary>
private static readonly SqlProviderServices _providerInstance = new SqlProviderServices();
+ private static readonly SqlTypesAssemblyLoader _sqlTypesAssemblyLoader = new SqlTypesAssemblyLoader();
+
/// <summary>
/// The Singleton instance of the SqlProviderServices type.
/// </summary>
@@ -49,7 +51,7 @@ public static SqlProviderServices Instance
/// </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>
+ /// <returns>an executable command definition object</returns>
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
{
@@ -263,7 +265,7 @@ protected override DbSpatialDataReader GetDbSpatialDataReader(DbDataReader fromR
{
throw new ProviderIncompatibleException(Strings.SqlProvider_NeedSqlDataReader(fromReader.GetType()));
}
- return new SqlSpatialDataReader(new SqlDataReaderWrapper(underlyingReader));
+ return new SqlSpatialDataReader(GetSpatialServices(versionHint), new SqlDataReaderWrapper(underlyingReader));
}
protected override DbSpatialServices DbGetSpatialServices(string versionHint)
@@ -289,32 +291,6 @@ private static void ValidateVersionHint(string versionHint)
}
}
- internal static SqlTypesAssembly GetSqlTypesAssembly()
- {
- SqlTypesAssembly sqlTypes;
- if (!TryGetSqlTypesAssembly(out sqlTypes))
- {
- throw new InvalidOperationException(Strings.SqlProvider_SqlTypesAssemblyNotFound);
- }
- Debug.Assert(sqlTypes != null);
- return sqlTypes;
- }
-
- internal static bool SqlTypesAssemblyIsAvailable
- {
- get
- {
- SqlTypesAssembly notUsed;
- return TryGetSqlTypesAssembly(out notUsed);
- }
- }
-
- private static bool TryGetSqlTypesAssembly(out SqlTypesAssembly sqlTypesAssembly)
- {
- sqlTypesAssembly = SqlTypesAssembly.Latest;
- return sqlTypesAssembly != null;
- }
-
/// <summary>
/// Creates a SqlParameter given a name, type, and direction
/// </summary>
@@ -453,14 +429,14 @@ internal static object EnsureSqlParameterValue(object value)
var geographyValue = value as DbGeography;
if (geographyValue != null)
{
- value = GetSqlTypesAssembly().ConvertToSqlTypesGeography(geographyValue);
+ value = _sqlTypesAssemblyLoader.GetSqlTypesAssembly().ConvertToSqlTypesGeography(geographyValue);
}
else
{
var geometryValue = value as DbGeometry;
if (geometryValue != null)
{
- value = GetSqlTypesAssembly().ConvertToSqlTypesGeometry(geometryValue);
+ value = _sqlTypesAssemblyLoader.GetSqlTypesAssembly().ConvertToSqlTypesGeometry(geometryValue);
}
}
}
View
21 src/EntityFramework.SqlServer/SqlSpatialDataReader.cs
@@ -16,12 +16,15 @@ namespace System.Data.Entity.SqlServer
/// </summary>
internal sealed class SqlSpatialDataReader : DbSpatialDataReader
{
+ private const string GeometrySqlType = "sys.geometry";
+ private const string GeographySqlType = "sys.geography";
+
+ private readonly DbSpatialServices _spatialServices;
private readonly SqlDataReaderWrapper _reader;
- private const string geometrySqlType = "sys.geometry";
- private const string geographySqlType = "sys.geography";
- internal SqlSpatialDataReader(SqlDataReaderWrapper underlyingReader)
+ internal SqlSpatialDataReader(DbSpatialServices spatialServices, SqlDataReaderWrapper underlyingReader)
{
+ _spatialServices = spatialServices;
_reader = underlyingReader;
}
@@ -30,7 +33,7 @@ public override DbGeography GetGeography(int ordinal)
EnsureGeographyColumn(ordinal);
var geogBytes = _reader.GetSqlBytes(ordinal);
var providerValue = _sqlGeographyFromBinaryReader.Value(new BinaryReader(geogBytes.Stream));
- return SqlSpatialServices.Instance.GeographyFromProviderValue(providerValue);
+ return _spatialServices.GeographyFromProviderValue(providerValue);
}
public override async Task<DbGeography> GetGeographyAsync(int ordinal, CancellationToken cancellationToken)
@@ -46,7 +49,7 @@ public override DbGeometry GetGeometry(int ordinal)
EnsureGeometryColumn(ordinal);
var geomBytes = _reader.GetSqlBytes(ordinal);
var providerValue = _sqlGeometryFromBinaryReader.Value(new BinaryReader(geomBytes.Stream));
- return SqlSpatialServices.Instance.GeometryFromProviderValue(providerValue);
+ return _spatialServices.GeometryFromProviderValue(providerValue);
}
public override async Task<DbGeometry> GetGeometryAsync(int ordinal, CancellationToken cancellationToken)
@@ -59,18 +62,18 @@ public override DbGeometry GetGeometry(int ordinal)
private static readonly Lazy<Func<BinaryReader, object>> _sqlGeographyFromBinaryReader =
new Lazy<Func<BinaryReader, object>>(
- () => CreateBinaryReadDelegate(SqlProviderServices.GetSqlTypesAssembly().SqlGeographyType), isThreadSafe: true);
+ () => CreateBinaryReadDelegate(new SqlTypesAssemblyLoader().GetSqlTypesAssembly().SqlGeographyType), isThreadSafe: true);
private static readonly Lazy<Func<BinaryReader, object>> _sqlGeometryFromBinaryReader =
new Lazy<Func<BinaryReader, object>>(
- () => CreateBinaryReadDelegate(SqlProviderServices.GetSqlTypesAssembly().SqlGeometryType), isThreadSafe: true);
+ () => CreateBinaryReadDelegate(new SqlTypesAssemblyLoader().GetSqlTypesAssembly().SqlGeometryType), isThreadSafe: true);
// test to ensure that the SQL column has the expected SQL type. Don't use the CLR type to avoid having to worry about differences in
// type versions between the client and the database.
private void EnsureGeographyColumn(int ordinal)
{
var fieldTypeName = _reader.GetDataTypeName(ordinal);
- if (!fieldTypeName.EndsWith(geographySqlType, StringComparison.Ordinal))
+ if (!fieldTypeName.EndsWith(GeographySqlType, StringComparison.Ordinal))
// Use EndsWith so that we just see the schema and type name, not the database name.
{
throw new InvalidDataException(Strings.SqlProvider_InvalidGeographyColumn(fieldTypeName));
@@ -80,7 +83,7 @@ private void EnsureGeographyColumn(int ordinal)
private void EnsureGeometryColumn(int ordinal)
{
var fieldTypeName = _reader.GetDataTypeName(ordinal);
- if (!fieldTypeName.EndsWith(geometrySqlType, StringComparison.Ordinal))
+ if (!fieldTypeName.EndsWith(GeometrySqlType, StringComparison.Ordinal))
// Use EndsWith so that we just see the schema and type name, not the database name.
{
throw new InvalidDataException(Strings.SqlProvider_InvalidGeometryColumn(fieldTypeName));
View
64 src/EntityFramework.SqlServer/SqlSpatialServices.cs
@@ -6,67 +6,83 @@
using System.Data.Entity.SqlServer.Utilities;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+ using System.Diagnostics.Contracts;
using System.Reflection;
using System.Runtime.Serialization;
[Serializable]
internal sealed class SqlSpatialServices : DbSpatialServices, ISerializable
{
- /// <summary>
- /// Do not allow instantiation
- /// </summary>
- internal static readonly SqlSpatialServices Instance = new SqlSpatialServices(SqlProviderServices.GetSqlTypesAssembly);
+ internal static readonly SqlSpatialServices Instance
+ = new SqlSpatialServices(new SqlTypesAssemblyLoader(), l => l.GetSqlTypesAssembly());
- private static Dictionary<string, SqlSpatialServices> otherSpatialServices;
+ private static Dictionary<string, SqlSpatialServices> _otherSpatialServices;
[NonSerialized]
private readonly Lazy<SqlTypesAssembly> _sqlTypesAssemblySingleton;
- internal SqlSpatialServices()
+ [NonSerialized]
+ private readonly SqlTypesAssemblyLoader _sqlTypesAssemblyLoader;
+
+ public SqlSpatialServices()
{
}
- private SqlSpatialServices(Func<SqlTypesAssembly> getSqlTypes)
+ public SqlSpatialServices(SqlTypesAssemblyLoader sqlTypesAssemblyLoader, Func<SqlTypesAssemblyLoader, SqlTypesAssembly> getSqlTypes)
{
- Debug.Assert(getSqlTypes != null, "Validate SqlTypes assembly delegate before constructing SqlSpatialServiceS");
- _sqlTypesAssemblySingleton = new Lazy<SqlTypesAssembly>(getSqlTypes, isThreadSafe: true);
+ Contract.Requires(getSqlTypes != null);
+ Contract.Requires(sqlTypesAssemblyLoader != null);
- // Create Singletons that will delay-initialize the MethodInfo and PropertyInfo instances used to invoke SqlGeography/SqlGeometry methods via reflection.
+ _sqlTypesAssemblyLoader = sqlTypesAssemblyLoader;
+ _sqlTypesAssemblySingleton = new Lazy<SqlTypesAssembly>(() => getSqlTypes(sqlTypesAssemblyLoader), isThreadSafe: true);
+
+ // Create Singletons that will delay-initialize the MethodInfo and PropertyInfo instances
+ // used to invoke SqlGeography/SqlGeometry methods via reflection.
InitializeMemberInfo();
}
- private SqlSpatialServices(SerializationInfo info, StreamingContext context)
+ public SqlSpatialServices(SerializationInfo info, StreamingContext context)
+ {
+ _sqlTypesAssemblyLoader = Instance._sqlTypesAssemblyLoader;
+ _sqlTypesAssemblySingleton = Instance._sqlTypesAssemblySingleton;
+ InitializeMemberInfo(Instance);
+ }
+
+ /// <inheritdoc/>
+ public override bool NativeTypesAvailable
{
- var instance = Instance;
- _sqlTypesAssemblySingleton = instance._sqlTypesAssemblySingleton;
- InitializeMemberInfo(instance);
+ get
+ {
+ return _sqlTypesAssemblyLoader.TryGetSqlTypesAssembly() != null;
+ }
}
// Given an assembly purportedly containing SqlServerTypes for spatial values, attempt to
- // create a corersponding Sql spefic DbSpatialServices value backed by types from that assembly.
+ // create a corresponding SQL specific DbSpatialServices value backed by types from that assembly.
// Uses a dictionary to ensure that there is at most db spatial service per assembly. It's important that
// this be done in a way that ensures that the underlying SqlTypesAssembly value is also atomized,
// since that's caching compilation.
// Relies on SqlTypesAssembly to verify that the assembly is appropriate.
private static bool TryGetSpatialServiceFromAssembly(Assembly assembly, out SqlSpatialServices services)
{
- if (otherSpatialServices == null
- || !otherSpatialServices.TryGetValue(assembly.FullName, out services))
+ if (_otherSpatialServices == null
+ || !_otherSpatialServices.TryGetValue(assembly.FullName, out services))
{
lock (Instance)
{
- if (otherSpatialServices == null
- || !otherSpatialServices.TryGetValue(assembly.FullName, out services))
+ if (_otherSpatialServices == null
+ || !_otherSpatialServices.TryGetValue(assembly.FullName, out services))
{
SqlTypesAssembly sqlAssembly;
- if (SqlTypesAssembly.TryGetSqlTypesAssembly(assembly, out sqlAssembly))
+ var loader = new SqlTypesAssemblyLoader();
+ if (loader.TryGetSqlTypesAssembly(assembly, out sqlAssembly))
{
- if (otherSpatialServices == null)
+ if (_otherSpatialServices == null)
{
- otherSpatialServices = new Dictionary<string, SqlSpatialServices>(1);
+ _otherSpatialServices = new Dictionary<string, SqlSpatialServices>(1);
}
- services = new SqlSpatialServices(() => sqlAssembly);
- otherSpatialServices.Add(assembly.FullName, services);
+ services = new SqlSpatialServices(loader, l => sqlAssembly);
+ _otherSpatialServices.Add(assembly.FullName, services);
}
else
{
View
110 src/EntityFramework.SqlServer/SqlTypesAssembly.cs
@@ -1,13 +1,10 @@
namespace System.Data.Entity.SqlServer
{
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
using System.Data.Entity.Spatial;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.IO;
- using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Xml;
@@ -15,115 +12,14 @@ namespace System.Data.Entity.SqlServer
/// <summary>
/// SqlTypesAssembly allows for late binding to the capabilities of a specific version of the Microsoft.SqlServer.Types assembly
/// </summary>
- internal sealed class SqlTypesAssembly
+ internal class SqlTypesAssembly
{
- private static readonly ReadOnlyCollection<string> _preferredSqlTypesAssemblies = new List<string>
- {
- "Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91",
- "Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91",
- }.AsReadOnly();
-
- private static SqlTypesAssembly BindToLatest()
- {
- Assembly sqlTypesAssembly = null;
- foreach (var assemblyFullName in _preferredSqlTypesAssemblies)
- {
- var asmName = new AssemblyName(assemblyFullName);
- try
- {
- sqlTypesAssembly = Assembly.Load(asmName);
- break;
- }
- catch (FileNotFoundException)
- {
- }
- catch (FileLoadException)
- {
- }
- }
-
- if (sqlTypesAssembly != null)
- {
- return new SqlTypesAssembly(sqlTypesAssembly);
- }
- return null;
- }
-
- internal static bool TryGetSqlTypesAssembly(Assembly assembly, out SqlTypesAssembly sqlAssembly)
- {
- if (IsKnownAssembly(assembly))
- {
- sqlAssembly = new SqlTypesAssembly(assembly);
- return true;
- }
- sqlAssembly = null;
- return false;
- }
-
- private static bool IsKnownAssembly(Assembly assembly)
- {
- foreach (var knownAssemblyFullName in _preferredSqlTypesAssemblies)
- {
- if (AssemblyNamesMatch(assembly.FullName, new AssemblyName(knownAssemblyFullName)))
- {
- return true;
- }
- }
- return false;
- }
-
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- private static bool AssemblyNamesMatch(string infoRowProviderAssemblyName, AssemblyName targetAssemblyName)
- {
- if (string.IsNullOrWhiteSpace(infoRowProviderAssemblyName))
- {
- return false;
- }
-
- AssemblyName assemblyName;
- try
- {
- assemblyName = new AssemblyName(infoRowProviderAssemblyName);
- }
- catch (Exception)
- {
- return false;
- }
-
- // Match the provider assembly details
- if (!string.Equals(targetAssemblyName.Name, assemblyName.Name, StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
-
- if (targetAssemblyName.Version == null
- || assemblyName.Version == null)
- {
- return false;
- }
-
- if (targetAssemblyName.Version.Major != assemblyName.Version.Major
- || targetAssemblyName.Version.Minor != assemblyName.Version.Minor)
- {
- return false;
- }
-
- var targetPublicKeyToken = targetAssemblyName.GetPublicKeyToken();
- return targetPublicKeyToken != null && targetPublicKeyToken.SequenceEqual(assemblyName.GetPublicKeyToken());
- }
-
- private static readonly Lazy<SqlTypesAssembly> _latestVersion = new Lazy<SqlTypesAssembly>(BindToLatest, isThreadSafe: true);
-
- /// <summary>
- /// Returns the highest available version of the Microsoft.SqlServer.Types assembly that could be located using Assembly.Load; may return <c>null</c> if no version of the assembly could be found.
- /// </summary>
- internal static SqlTypesAssembly Latest
+ public SqlTypesAssembly()
{
- get { return _latestVersion.Value; }
}
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
- private SqlTypesAssembly(Assembly sqlSpatialAssembly)
+ public SqlTypesAssembly(Assembly sqlSpatialAssembly)
{
// Retrieve SQL Server spatial types and static constructor methods
var sqlGeog = sqlSpatialAssembly.GetType("Microsoft.SqlServer.Types.SqlGeography", throwOnError: true);
View
137 src/EntityFramework.SqlServer/SqlTypesAssemblyLoader.cs
@@ -0,0 +1,137 @@
+namespace System.Data.Entity.SqlServer
+{
+ using System.Collections.Generic;
+ using System.Collections.ObjectModel;
+ using System.Data.Entity.SqlServer.Resources;
+ using System.Diagnostics.CodeAnalysis;
+ using System.IO;
+ using System.Linq;
+ using System.Reflection;
+
+ internal class SqlTypesAssemblyLoader
+ {
+ private readonly IEnumerable<string> _preferredSqlTypesAssemblies;
+
+ private readonly Lazy<SqlTypesAssembly> _latestVersion;
+
+ public SqlTypesAssemblyLoader(IEnumerable<string> assemblyNames = null)
+ {
+ _preferredSqlTypesAssemblies
+ = assemblyNames
+ ?? new[]
+ {
+ "Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91",
+ "Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91",
+ };
+
+ _latestVersion = new Lazy<SqlTypesAssembly>(BindToLatest, isThreadSafe: true);
+ }
+
+ /// <summary>
+ /// Returns the highest available version of the Microsoft.SqlServer.Types assembly that could be
+ /// located using Assembly.Load; may return <c>null</c> if no version of the assembly could be found.
+ /// </summary>
+ public virtual SqlTypesAssembly TryGetSqlTypesAssembly()
+ {
+ return _latestVersion.Value;
+ }
+
+ public virtual SqlTypesAssembly GetSqlTypesAssembly()
+ {
+ if (_latestVersion.Value == null)
+ {
+ throw new InvalidOperationException(Strings.SqlProvider_SqlTypesAssemblyNotFound);
+ }
+ return _latestVersion.Value;
+ }
+
+ public virtual bool TryGetSqlTypesAssembly(Assembly assembly, out SqlTypesAssembly sqlAssembly)
+ {
+ if (IsKnownAssembly(assembly))
+ {
+ sqlAssembly = new SqlTypesAssembly(assembly);
+ return true;
+ }
+ sqlAssembly = null;
+ return false;
+ }
+
+ private SqlTypesAssembly BindToLatest()
+ {
+ Assembly sqlTypesAssembly = null;
+ foreach (var assemblyFullName in _preferredSqlTypesAssemblies)
+ {
+ var asmName = new AssemblyName(assemblyFullName);
+ try
+ {
+ sqlTypesAssembly = Assembly.Load(asmName);
+ break;
+ }
+ catch (FileNotFoundException)
+ {
+ }
+ catch (FileLoadException)
+ {
+ }
+ }
+
+ if (sqlTypesAssembly != null)
+ {
+ return new SqlTypesAssembly(sqlTypesAssembly);
+ }
+ return null;
+ }
+
+ private bool IsKnownAssembly(Assembly assembly)
+ {
+ foreach (var knownAssemblyFullName in _preferredSqlTypesAssemblies)
+ {
+ if (AssemblyNamesMatch(assembly.FullName, new AssemblyName(knownAssemblyFullName)))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ private static bool AssemblyNamesMatch(string infoRowProviderAssemblyName, AssemblyName targetAssemblyName)
+ {
+ if (string.IsNullOrWhiteSpace(infoRowProviderAssemblyName))
+ {
+ return false;
+ }
+
+ AssemblyName assemblyName;
+ try
+ {
+ assemblyName = new AssemblyName(infoRowProviderAssemblyName);
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+
+ // Match the provider assembly details
+ if (!string.Equals(targetAssemblyName.Name, assemblyName.Name, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ if (targetAssemblyName.Version == null
+ || assemblyName.Version == null)
+ {
+ return false;
+ }
+
+ if (targetAssemblyName.Version.Major != assemblyName.Version.Major
+ || targetAssemblyName.Version.Minor != assemblyName.Version.Minor)
+ {
+ return false;
+ }
+
+ var targetPublicKeyToken = targetAssemblyName.GetPublicKeyToken();
+ return targetPublicKeyToken != null && targetPublicKeyToken.SequenceEqual(assemblyName.GetPublicKeyToken());
+ }
+ }
+}
View
2  src/EntityFramework.SqlServerCompact/SqlCeProviderServices.cs
@@ -310,7 +310,7 @@ private static bool InTransactionScope()
/// </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>
+ /// <returns>an executable command definition object</returns>
protected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
{
Debug.Assert(providerManifest != null, "CreateCommandDefinition passed null provider manifest to CreateDbCommandDefinition?");
View
18 src/EntityFramework/Config/AppConfigDependencyResolver.cs
@@ -3,6 +3,10 @@ namespace System.Data.Entity.Config
using System.Data.Entity.Core.Common;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Internal;
+ using System.Data.Entity.Migrations.Infrastructure;
+ using System.Data.Entity.Migrations.Sql;
+ using System.Data.Entity.Resources;
+ using System.Data.Entity.Utilities;
using System.Diagnostics.Contracts;
// TODO: Consider thread safety
@@ -23,12 +27,16 @@ public AppConfigDependencyResolver(AppConfig appConfig)
public virtual object GetService(Type type, string name)
{
- if (type == typeof(DbProviderServices) && !string.IsNullOrWhiteSpace(name))
+ if (!string.IsNullOrWhiteSpace(name))
{
- var providerTypeName = _appConfig.Providers.TryGetDbProviderServicesTypeName(name);
- if (providerTypeName != null)
+ if (type == typeof(DbProviderServices))
{
- return new ProviderServicesFactory().GetInstance(providerTypeName, name);
+ return _appConfig.Providers.TryGetDbProviderServices(name);
+ }
+
+ if (type == typeof(MigrationSqlGenerator))
+ {
+ return _appConfig.Providers.TryGetMigrationSqlGenerator(name);
}
}
@@ -46,4 +54,4 @@ public virtual void Release(object service)
{
}
}
-}
+}
View
4 src/EntityFramework/Config/CompositeResolver`.cs
@@ -8,7 +8,7 @@ namespace System.Data.Entity.Config
/// </summary>
internal class CompositeResolver<TFirst, TSecond> : IDbDependencyResolver
where TFirst : IDbDependencyResolver
- where TSecond :IDbDependencyResolver
+ where TSecond : IDbDependencyResolver
{
private readonly TFirst _firstResolver;
@@ -44,4 +44,4 @@ public virtual void Release(object service)
_secondResolver.Release(service);
}
}
-}
+}
View
33 src/EntityFramework/Config/DbConfiguration.cs
@@ -18,7 +18,8 @@ namespace System.Data.Entity.Config
public class DbConfiguration
{
private readonly CompositeResolver<ResolverChain, ResolverChain> _resolvers;
-
+ private readonly RootDependencyResolver _rootResolver;
+
private bool _isLocked;
/// <summary>
@@ -26,18 +27,21 @@ public class DbConfiguration
/// and that constructor should call this constructor.
/// </summary>
protected internal DbConfiguration()
- : this(new ResolverChain(), new ResolverChain())
+ : this(
+ new ResolverChain(), new ResolverChain(),
+ new RootDependencyResolver(new MigrationsConfigurationResolver(), new DefaultProviderServicesResolver()))
{
_resolvers.First.Add(new AppConfigDependencyResolver(AppConfig.DefaultInstance));
- _resolvers.Second.Add(new RootDependencyResolver());
}
- internal DbConfiguration(ResolverChain appConfigChain, ResolverChain normalResolverChain)
+ internal DbConfiguration(ResolverChain appConfigChain, ResolverChain normalResolverChain, RootDependencyResolver rootResolver)
{
Contract.Requires(appConfigChain != null);
Contract.Requires(normalResolverChain != null);
+ _rootResolver = rootResolver;
_resolvers = new CompositeResolver<ResolverChain, ResolverChain>(appConfigChain, normalResolverChain);
+ _resolvers.Second.Add(_rootResolver);
}
/// <summary>
@@ -173,10 +177,21 @@ protected internal set
AddDependencyResolver(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(value));
}
- get
- {
- return _resolvers.GetService<IDbModelCacheKeyFactory>();
- }
+ get { return _resolvers.GetService<IDbModelCacheKeyFactory>(); }
+ }
+
+ /// <summary>
+ /// Gets the <see cref="IDbDependencyResolver"/> that is being used to resolve service
+ /// dependencies in the Entity Framework.
+ /// </summary>
+ public virtual IDbDependencyResolver DependencyResolver
+ {
+ get { return _resolvers; }
+ }
+
+ internal virtual RootDependencyResolver RootResolver
+ {
+ get { return _rootResolver; }
}
private void CheckNotLocked(string memberName)
@@ -187,4 +202,4 @@ private void CheckNotLocked(string memberName)
}
}
}
-}
+}
View
33 src/EntityFramework/Config/DbConfigurationFinder.cs
@@ -2,6 +2,7 @@ namespace System.Data.Entity.Config
{
using System.Collections.Generic;
using System.Data.Entity.Resources;
+ using System.Data.Entity.Utilities;
using System.Diagnostics.Contracts;
using System.Linq;
@@ -34,17 +35,19 @@ public virtual Type TryFindConfigurationType(IEnumerable<Type> typesToSearch)
var proxyConfigs = configurations.Where(c => typeof(DbConfigurationProxy).IsAssignableFrom(c));
if (proxyConfigs.Count() > 1)
{
- throw new InvalidOperationException(Strings.MultipleConfigsInAssembly(proxyConfigs.First().Assembly, typeof(DbConfigurationProxy).Name));
+ throw new InvalidOperationException(
+ Strings.MultipleConfigsInAssembly(proxyConfigs.First().Assembly, typeof(DbConfigurationProxy).Name));
}
if (proxyConfigs.Count() == 1)
{
- return CreateConfiguration<DbConfigurationProxy>(proxyConfigs.First()).ConfigurationToUse();
+ return proxyConfigs.First().CreateInstance<DbConfigurationProxy>().ConfigurationToUse();
}
// Else if there is exactly one normal config then use it, otherwise return null.
if (configurations.Count > 1)
{
- throw new InvalidOperationException(Strings.MultipleConfigsInAssembly(configurations.First().Assembly, typeof(DbConfiguration).Name));
+ throw new InvalidOperationException(
+ Strings.MultipleConfigsInAssembly(configurations.First().Assembly, typeof(DbConfiguration).Name));
}
return configurations.FirstOrDefault();
@@ -58,29 +61,7 @@ public virtual DbConfiguration TryCreateConfiguration(IEnumerable<Type> typesToS
return configType == null || typeof(DbNullConfiguration).IsAssignableFrom(configType)
? null
- : CreateConfiguration<DbConfiguration>(configType);
- }
-
- public static TConfig CreateConfiguration<TConfig>(Type configurationType) where TConfig : DbConfiguration
- {
- Contract.Requires(typeof(TConfig).IsAssignableFrom(configurationType));
-
- if (configurationType.GetConstructor(Type.EmptyTypes) == null)
- {
- throw new InvalidOperationException(Strings.Configuration_NoParameterlessConstructor(configurationType));
- }
-
- if (configurationType.IsAbstract)
- {
- throw new InvalidOperationException(Strings.Configuration_AbstractConfigurationType(configurationType));
- }
-
- if (configurationType.IsGenericType)
- {
- throw new InvalidOperationException(Strings.Configuration_GenericConfigurationType(configurationType));
- }
-
- return (TConfig)Activator.CreateInstance(configurationType);
+ : configType.CreateInstance<DbConfiguration>();
}
}
}
View
2  src/EntityFramework/Config/DbConfigurationLoader.cs
@@ -10,4 +10,4 @@ public virtual DbConfiguration TryLoadFromConfig(AppConfig config)
return null;
}
}
-}
+}
View
26 src/EntityFramework/Config/DbConfigurationManager.cs
@@ -24,6 +24,7 @@ internal class DbConfigurationManager
private readonly DbConfigurationFinder _finder;
private readonly ISet<Assembly> _knownAssemblies = new HashSet<Assembly>();
private DbConfiguration _configuration;
+
private readonly IList<Tuple<AppConfig, DbConfiguration>> _configurationOverrides
= new List<Tuple<AppConfig, DbConfiguration>>();
@@ -35,7 +36,7 @@ public DbConfigurationManager(DbConfigurationLoader loader, DbConfigurationFinde
_loader = loader;
_finder = finder;
}
-
+
public static DbConfigurationManager Instance
{
get { return _configManager; }
@@ -67,14 +68,17 @@ public virtual void SetConfiguration(DbConfiguration configuration)
_configuration = configuration;
_configuration.Lock();
}
- else if (_configuration.GetType() != configuration.GetType())
+ else if (_configuration.GetType()
+ != configuration.GetType())
{
- if (_configuration.GetType() == typeof(DbConfiguration))
+ if (_configuration.GetType()
+ == typeof(DbConfiguration))
{
throw new InvalidOperationException(Strings.DefaultConfigurationUsedBeforeSet(configuration.GetType().Name));
}
- throw new InvalidOperationException(Strings.ConfigurationSetTwice(configuration.GetType().Name, _configuration.GetType().Name));
+ throw new InvalidOperationException(
+ Strings.ConfigurationSetTwice(configuration.GetType().Name, _configuration.GetType().Name));
}
}
@@ -82,11 +86,11 @@ public virtual void EnsureLoadedForContext(Type contextType)
{
Contract.Requires(contextType != null);
Contract.Requires(typeof(DbContext).IsAssignableFrom(contextType));
-
+
var contextAssembly = contextType.Assembly;
if (contextType == typeof(DbContext)
- || _knownAssemblies.Contains(contextAssembly)
+ || _knownAssemblies.Contains(contextAssembly)
|| _configurationOverrides.Count != 0)
{
return;
@@ -105,7 +109,8 @@ public virtual void EnsureLoadedForContext(Type contextType)
var foundType = _finder.TryFindConfigurationType(contextType.Assembly.GetAccessibleTypes());
if (!typeof(DbNullConfiguration).IsAssignableFrom(foundType))
{
- if (_configuration.GetType() == typeof(DbConfiguration))
+ if (_configuration.GetType()
+ == typeof(DbConfiguration))
{
if (foundType != null)
{
@@ -114,7 +119,8 @@ public virtual void EnsureLoadedForContext(Type contextType)
}
else
{
- if (foundType == null || foundType != _configuration.GetType())
+ if (foundType == null
+ || foundType != _configuration.GetType())
{
throw new InvalidOperationException(
Strings.SetConfigurationNotDiscovered(_configuration.GetType().Name, contextType.Name));
@@ -131,7 +137,7 @@ public virtual void PushConfiguration(AppConfig config, Type contextType)
Contract.Requires(config != null);
Contract.Requires(contextType != null);
Contract.Requires(typeof(DbContext).IsAssignableFrom(contextType));
-
+
var configuration = _loader.TryLoadFromConfig(config)
?? _finder.TryCreateConfiguration(contextType.Assembly.GetAccessibleTypes())
?? new DbConfiguration();
@@ -153,4 +159,4 @@ public virtual void PopConfiguration(AppConfig config)
}
}
}
-}
+}
View
2  src/EntityFramework/Config/DbConfigurationProxy.cs
@@ -16,4 +16,4 @@ public abstract class DbConfigurationProxy : DbConfiguration
/// <returns>The <see cref="DbConfiguration"/> type to use.</returns>
public abstract Type ConfigurationToUse();
}
-}
+}
View
2  src/EntityFramework/Config/DbNullConfiguration.cs
@@ -10,4 +10,4 @@ namespace System.Data.Entity.Config
public class DbNullConfiguration : DbConfiguration
{
}
-}
+}
View
27 src/EntityFramework/Config/DefaultProviderServicesResolver.cs
@@ -0,0 +1,27 @@
+namespace System.Data.Entity.Config
+{
+ using System.Data.Entity.Core.Common;
+ using System.Data.Entity.Resources;
+
+ internal class DefaultProviderServicesResolver : IDbDependencyResolver
+ {
+ public virtual object GetService(Type type, string name)
+ {
+ if (type == typeof(DbProviderServices))
+ {
+ if (string.IsNullOrWhiteSpace(name))
+ {
+ throw new ArgumentException(Strings.ProviderInvariantNotPassedToResolver);
+ }
+
+ return new ProviderServicesFactory().GetInstanceByConvention(name);
+ }
+
+ return null;
+ }
+
+ public virtual void Release(object service)
+ {
+ }
+ }
+}
View
2  src/EntityFramework/Config/IDbDependencyResolver.cs
@@ -1,7 +1,5 @@
namespace System.Data.Entity.Config
{
- using System.Diagnostics.CodeAnalysis;
-
/// <summary>
/// This interface is implemented by any object that can resolve a dependency, either directly
/// or through use of an external container.
View
2  src/EntityFramework/Config/IDbDependencyResolverExtensions.cs
@@ -52,4 +52,4 @@ public static object GetService(this IDbDependencyResolver resolver, Type type)
return resolver.GetService(type, null);
}
}
-}
+}
View
39 src/EntityFramework/Config/MigrationsConfigurationResolver.cs
@@ -0,0 +1,39 @@
+namespace System.Data.Entity.Config
+{
+ using System.Collections.Generic;
+ using System.Data.Entity.Migrations.Sql;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Diagnostics.Contracts;
+
+ internal class MigrationsConfigurationResolver : IDbDependencyResolver
+ {
+ private readonly Dictionary<string, MigrationSqlGenerator> _sqlGenerators
+ = new Dictionary<string, MigrationSqlGenerator>();
+
+ [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+ public MigrationsConfigurationResolver()
+ {
+ SetSqlGenerator("System.Data.SqlClient", new SqlServerMigrationSqlGenerator());
+ SetSqlGenerator("System.Data.SqlServerCe.4.0", new SqlCeMigrationSqlGenerator());
+ }
+
+ public virtual void SetSqlGenerator(string providerInvariantName, MigrationSqlGenerator migrationSqlGenerator)
+ {
+ Contract.Requires(!string.IsNullOrWhiteSpace(providerInvariantName));
+ Contract.Requires(migrationSqlGenerator != null);
+
+ _sqlGenerators[providerInvariantName] = migrationSqlGenerator;
+ }
+
+ public virtual object GetService(Type type, string name)
+ {
+ return type == typeof(MigrationSqlGenerator) && !string.IsNullOrWhiteSpace(name) && _sqlGenerators.ContainsKey(name)
+ ? _sqlGenerators[name]
+ : null;
+ }
+
+ public virtual void Release(object service)
+ {
+ }
+ }
+}
View
2  src/EntityFramework/Config/ProviderServicesFactory.cs
@@ -63,4 +63,4 @@ public virtual DbProviderServices GetInstanceByConvention(string providerInvaria
providerInvariantName);
}
}
-}
+}
View
2  src/EntityFramework/Config/ResolverChain.cs
@@ -32,4 +32,4 @@ public virtual void Release(object service)
_resolvers.Each(r => r.Release(service));
}
}
-}
+}
View
48 src/EntityFramework/Config/RootDependencyResolver.cs
@@ -1,10 +1,7 @@
namespace System.Data.Entity.Config
{
- using System.Data.Entity.Core.Common;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Internal;
- using System.Data.Entity.Resources;
- using System.Diagnostics.Contracts;
// TODO: Consider thread safety
// TODO: Consider caching for perf
@@ -15,39 +12,38 @@ namespace System.Data.Entity.Config
/// </summary>
internal class RootDependencyResolver : IDbDependencyResolver
{
- /// <inheritdoc/>
- public virtual object GetService(Type type, string name)
- {
- // TODO: Handle Database initializer
+ private readonly MigrationsConfigurationResolver _migrationsConfigurationResolver;
+ private readonly ResolverChain _resolvers = new ResolverChain();
- if (type == typeof(DbProviderServices))
- {
- if (string.IsNullOrWhiteSpace(name))
- {
- throw new ArgumentException(Strings.ProviderInvariantNotPassedToResolver);
- }
-
- return new ProviderServicesFactory().GetInstanceByConvention(name);
- }
+ public RootDependencyResolver(
+ MigrationsConfigurationResolver migrationsConfigurationResolver,
+ DefaultProviderServicesResolver defaultProviderServicesResolver)
+ {
+ _migrationsConfigurationResolver = migrationsConfigurationResolver;
- if (type == typeof(IDbConnectionFactory))
- {
- return new SqlConnectionFactory();
- }
+ _resolvers.Add(_migrationsConfigurationResolver);
+ _resolvers.Add(defaultProviderServicesResolver);
+ _resolvers.Add(new SingletonDependencyResolver<IDbConnectionFactory>(new SqlConnectionFactory()));
+ _resolvers.Add(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory()));
+ }
- if (type == typeof(IDbModelCacheKeyFactory))
- {
- return new DefaultModelCacheKeyFactory();
- }
+ public MigrationsConfigurationResolver MigrationsConfigurationResolver
+ {
+ get { return _migrationsConfigurationResolver; }
+ }
- Contract.Assert(false, "End of resolver chain reached without resolving dependency.");
+ /// <inheritdoc/>
+ public virtual object GetService(Type type, string name)
+ {
+ // TODO: Handle Database initializer
- return null;
+ return _resolvers.GetService(type, name);
}
/// <inheritdoc/>
public virtual void Release(object service)
{
+ _resolvers.Release(service);
}
}
}
View
2  src/EntityFramework/Config/SingletonDependencyResolver.cs
@@ -49,4 +49,4 @@ public void Release(object service)
{
}
}
-}
+}
View
44 src/EntityFramework/Core/Common/CommandTrees/DefaultExpressionVisitor.cs
@@ -185,17 +185,17 @@ protected virtual DbLambda VisitLambda(DbLambda lambda)
var result = lambda;
var newFormals = VisitList(
lambda.Variables, varRef =>
- {
- var newVarType = VisitTypeUsage(varRef.ResultType);
- if (!ReferenceEquals(varRef.ResultType, newVarType))
- {
- return CqtBuilder.Variable(newVarType, varRef.VariableName);
- }
- else
- {
- return varRef;
- }
- }
+ {
+ var newVarType = VisitTypeUsage(varRef.ResultType);
+ if (!ReferenceEquals(varRef.ResultType, newVarType))
+ {
+ return CqtBuilder.Variable(newVarType, varRef.VariableName);
+ }
+ else
+ {
+ return varRef;
+ }
+ }
);
EnterScope(newFormals.ToArray()); // ToArray: Don't pass the List instance directly to OnEnterScope
var newBody = VisitExpression(lambda.Body);
@@ -546,17 +546,17 @@ public override DbExpression Visit(DbIsNullExpression expression)
{
return VisitUnary(
expression, exp =>
- {
- if (TypeSemantics.IsRowType(exp.ResultType))
- {
- // TODO: Remove this special, non-public, overload that derived classes cannot access
- return CqtBuilder.CreateIsNullExpressionAllowingRowTypeArgument(exp);
- }
- else
- {
- return CqtBuilder.IsNull(exp);
- }
- }
+ {
+ if (TypeSemantics.IsRowType(exp.ResultType))
+ {
+ // TODO: Remove this special, non-public, overload that derived classes cannot access
+ return CqtBuilder.CreateIsNullExpressionAllowingRowTypeArgument(exp);
+ }
+ else
+ {
+ return CqtBuilder.IsNull(exp);
+ }
+ }
);
}
View
102 ...EntityFramework/Core/Common/CommandTrees/ExpressionBuilder/Internal/ArgumentValidation.cs
@@ -337,16 +337,16 @@ internal static DbExpressionList ValidateFunctionAggregate(EdmFunction function,
var expectedParams = GetExpectedParameters(function);
var funcArgs = CreateExpressionList(
args, "argument", expectedParams.Length, (exp, idx) =>
- {
- var paramType = expectedParams[idx].TypeUsage;
- TypeUsage elementType = null;
- if (TypeHelpers.TryGetCollectionElementType(paramType, out elementType))
- {
- paramType = elementType;
- }
-
- RequireCompatibleType(exp, paramType, "argument");
- }
+ {
+ var paramType = expectedParams[idx].TypeUsage;
+ TypeUsage elementType = null;
+ if (TypeHelpers.TryGetCollectionElementType(paramType, out elementType))
+ {
+ paramType = elementType;
+ }
+
+ RequireCompatibleType(exp, paramType, "argument");
+ }
);
return funcArgs;
@@ -1441,21 +1441,21 @@ internal static TypeUsage ValidateLimit(DbExpression argument, DbExpression limi
TypeUsage commonResultType = null;
validThens = CreateExpressionList(
thenExpressions, "thenExpressions", (exp, idx) =>
- {
- if (null == commonResultType)
- {
- commonResultType = exp.ResultType;
- }
- else
- {
- commonResultType = TypeHelpers.GetCommonTypeUsage(
- exp.ResultType, commonResultType);
- if (null == commonResultType)
- {
- throw new ArgumentException(Strings.Cqt_Case_InvalidResultType);
- }
- }
- }
+ {
+ if (null == commonResultType)
+ {
+ commonResultType = exp.ResultType;
+ }
+ else
+ {
+ commonResultType = TypeHelpers.GetCommonTypeUsage(
+ exp.ResultType, commonResultType);
+ if (null == commonResultType)
+ {
+ throw new ArgumentException(Strings.Cqt_Case_InvalidResultType);
+ }
+ }
+ }
);
Debug.Assert(validWhens.Count > 0, "CreateExpressionList(arguments, argumentName, validationCallback) allowed empty Thens?");
@@ -1530,10 +1530,10 @@ internal static TypeUsage ValidateInvoke(DbLambda lambda, IEnumerable<DbExpressi
validArguments = null;
var argValidator = CreateValidator(
arguments, "arguments", (exp, idx) =>
- {
- RequireCompatibleType(exp, lambda.Variables[idx].ResultType, "arguments", idx);
- return exp;
- },
+ {
+ RequireCompatibleType(exp, lambda.Variables[idx].ResultType, "arguments", idx);
+ return exp;
+ },
expList => new DbExpressionList(expList)
);
argValidator.ExpectedElementCount = lambda.Variables.Count;
@@ -1549,22 +1549,22 @@ internal static TypeUsage ValidateNewCollection(IEnumerable<DbExpression> elemen
TypeUsage commonElementType = null;
validElements = CreateExpressionList(
elements, "elements", (exp, idx) =>
- {
- if (commonElementType == null)
- {
- commonElementType = exp.ResultType;
- }
- else
- {
- commonElementType = TypeSemantics.GetCommonType(commonElementType, exp.ResultType);
- }
-
- if (null == commonElementType)
- {
- throw new ArgumentException(
- Strings.Cqt_Factory_NewCollectionInvalidCommonType, "collectionElements");
- }
- }
+ {
+ if (commonElementType == null)
+ {
+ commonElementType = exp.ResultType;
+ }
+ else
+ {
+ commonElementType = TypeSemantics.GetCommonType(commonElementType, exp.ResultType);
+ }
+
+ if (null == commonElementType)
+ {
+ throw new ArgumentException(
+ Strings.Cqt_Factory_NewCollectionInvalidCommonType, "collectionElements");
+ }
+ }
);
Debug.Assert(
@@ -1597,12 +1597,12 @@ internal static TypeUsage ValidateNewEmptyCollection(TypeUsage collectionType, o
var columnTypes = new List<KeyValuePair<string, TypeUsage>>();
var columnValidator = CreateValidator(
columnValues, "columnValues", (columnValue, idx) =>
- {
- CheckNamed(columnValue, "columnValues", idx);
- columnTypes.Add(
- new KeyValuePair<string, TypeUsage>(columnValue.Key, columnValue.Value.ResultType));
- return columnValue.Value;
- },
+ {
+ CheckNamed(columnValue, "columnValues", idx);
+ columnTypes.Add(
+ new KeyValuePair<string, TypeUsage>(columnValue.Key, columnValue.Value.ResultType));
+ return columnValue.Value;
+ },
expList => new DbExpressionList(expList)
);
columnValidator.GetName = ((columnValue, idx) => columnValue.Key);
View
96 src/EntityFramework/Core/Common/CommandTrees/Internal/Patterns.cs
@@ -187,18 +187,18 @@ internal static class Patterns
Func<DbExpression, bool> inputPattern, Func<DbExpression, bool> predicatePattern)
{
return (e =>
- {
- if (e.ExpressionKind
- != DbExpressionKind.Filter)
- {
- return false;
- }
- else
- {
- var filterEx = (DbFilterExpression)e;
- return inputPattern(filterEx.Input.Expression) && predicatePattern(filterEx.Predicate);
- }
- });
+ {
+ if (e.ExpressionKind
+ != DbExpressionKind.Filter)
+ {
+ return false;
+ }
+ else
+ {
+ var filterEx = (DbFilterExpression)e;
+ return inputPattern(filterEx.Input.Expression) && predicatePattern(filterEx.Predicate);
+ }
+ });
}
/// <summary>
@@ -208,18 +208,18 @@ internal static class Patterns
Func<DbExpression, bool> inputPattern, Func<DbExpression, bool> projectionPattern)
{
return (e =>
- {
- if (e.ExpressionKind
- != DbExpressionKind.Project)
- {
- return false;
- }
- else
- {
- var projectEx = (DbProjectExpression)e;
- return inputPattern(projectEx.Input.Expression) && projectionPattern(projectEx.Projection);
- }
- });
+ {
+ if (e.ExpressionKind
+ != DbExpressionKind.Project)
+ {
+ return false;
+ }
+ else
+ {
+ var projectEx = (DbProjectExpression)e;
+ return inputPattern(projectEx.Input.Expression) && projectionPattern(projectEx.Projection);
+ }
+ });
}
/// <summary>
@@ -230,18 +230,18 @@ internal static class Patterns
Func<DbExpression, bool> elsePattern)
{
return (e =>
- {
- if (e.ExpressionKind
- != DbExpressionKind.Case)
- {
- return false;
- }
- else
- {
- var caseEx = (DbCaseExpression)e;
- return whenPattern(caseEx.When) && thenPattern(caseEx.Then) && elsePattern(caseEx.Else);
- }
- });
+ {
+ if (e.ExpressionKind
+ != DbExpressionKind.Case)
+ {
+ return false;
+ }
+ else
+ {
+ var caseEx = (DbCaseExpression)e;
+ return whenPattern(caseEx.When) && thenPattern(caseEx.Then) && elsePattern(caseEx.Else);
+ }
+ });
}
/// <summary>
@@ -258,18 +258,18 @@ internal static class Patterns
internal static Func<DbExpression, bool> MatchNewInstance(Func<IEnumerable<DbExpression>, bool> argumentsPattern)
{
return (e =>
- {
- if (e.ExpressionKind
- != DbExpressionKind.NewInstance)
- {
- return false;
- }
- else
- {
- var newInst = (DbNewInstanceExpression)e;
- return argumentsPattern(newInst.Arguments);
- }
- });
+ {
+ if (e.ExpressionKind
+ != DbExpressionKind.NewInstance)
+ {
+ return false;
+ }
+ else
+ {
+ var newInst = (DbNewInstanceExpression)e;
+ return argumentsPattern(newInst.Arguments);
+ }
+ });
}
#endregion
View
62 src/EntityFramework/Core/Common/DbProviderServices.cs
@@ -1,6 +1,7 @@
namespace System.Data.Entity.Core.Common
{
using System.Data.Common;
+ using System.Data.Entity.Config;
using System.Data.Entity.Core.Common.CommandTrees;
using System.Data.Entity.Core.EntityClient.Internal;
using System.Data.Entity.Core.Metadata.Edm;
@@ -21,11 +22,35 @@ namespace System.Data.Entity.Core.Common
[CLSCompliant(false)]
public abstract class DbProviderServices
{
+ private readonly Lazy<IDbDependencyResolver> _resolver;
+
+ /// <summary>
+ /// Constructs an EF provider that will use the <see cref="IDbDependencyResolver"/> obtained from
+ /// the app domain <see cref="DbConfiguration"/> Singleton for resolving EF dependencies such
+ /// as the <see cref="DbSpatialServices"/> instance to use.
+ /// </summary>
+ protected DbProviderServices()
+ {
+ _resolver = new Lazy<IDbDependencyResolver>(() => DbConfiguration.Instance.DependencyResolver);
+ }
+
+ /// <summary>
+ /// Constructs an EF provider that will use the given <see cref="IDbDependencyResolver"/> for
+ /// resolving EF dependencies such as the <see cref="DbSpatialServices"/> instance to use.
+ /// </summary>
+ /// <param name="resolver">The resolver to use.</param>
+ protected DbProviderServices(IDbDependencyResolver resolver)
+ {
+ Contract.Requires(resolver != null);
+
+ _resolver = new Lazy<IDbDependencyResolver>(() => resolver);
+ }
+
/// <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>
+ /// <returns>an executable command definition object</returns>
/// <remarks>
/// This method simply delegates to the provider's implementation of CreateDbCommandDefinition.
/// </remarks>
@@ -43,7 +68,7 @@ public DbCommandDefinition CreateCommandDefinition(DbCommandTree commandTree)
/// 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>
+ /// <returns>an executable command definition object</returns>
/// <remarks>
/// This method simply delegates to the provider's implementation of CreateDbCommandDefinition.
/// </remarks>
@@ -72,7 +97,7 @@ public DbCommandDefinition CreateCommandDefinition(DbProviderManifest providerMa
/// </summary>
/// <param name="connection">provider manifest previously retrieved from the store provider</param>
/// <param name="commandTree">command tree for the statement</param>
- /// <returns>an exectable command definition object</returns>
+ /// <returns>an executable command definition object</returns>
protected abstract DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree);
/// <summary>
@@ -208,15 +233,19 @@ public DbSpatialDataReader GetSpatialDataReader(DbDataReader fromReader, string
public DbSpatialServices GetSpatialServices(string manifestToken)
{
- try
+ Contract.Ensures(Contract.Result<DbSpatialServices>() != null);
+
+ // First check if spatial services can be resolved and only if this fails
+ // go on to ask the provider for spatial services.
+ var spatialProvider = _resolver.Value.GetService<DbSpatialServices>();
+ if (spatialProvider != null)
{
- var spatialServices = DbGetSpatialServices(manifestToken);
- if (spatialServices == null)
- {
- throw new ProviderIncompatibleException(Strings.ProviderDidNotReturnSpatialServices);
- }
+ return spatialProvider;
+ }
- return spatialServices;
+ try
+ {
+ spatialProvider = DbGetSpatialServices(manifestToken);
}
catch (ProviderIncompatibleException)
{
@@ -224,12 +253,15 @@ public DbSpatialServices GetSpatialServices(string manifestToken)
}
catch (Exception e)
{
- if (e.IsCatchableExceptionType())
- {
- throw new ProviderIncompatibleException(Strings.ProviderDidNotReturnSpatialServices, e);
- }
- throw;
+ throw new ProviderIncompatibleException(Strings.ProviderDidNotReturnSpatialServices, e);
}
+
+ if (spatialProvider == null)
+ {
+ throw new ProviderIncompatibleException(Strings.ProviderDidNotReturnSpatialServices);
+ }
+
+ return spatialProvider;
}
protected virtual DbSpatialDataReader GetDbSpatialDataReader(DbDataReader fromReader, string manifestToken)
View
1,550 src/EntityFramework/Core/Common/EntitySql/CqlLexer.cs
@@ -72,93 +72,93 @@ private CqlLexer()
yy_at_bol = true;
yy_lexical_state = YYINITIAL;
accept_dispatch = new[]
- {
- null,
- null,
- Accept_2,
- Accept_3,
- Accept_4,
- Accept_5,
- Accept_6,
- Accept_7,
- Accept_8,
- Accept_9,
- Accept_10,
- Accept_11,
- Accept_12,
- Accept_13,
- Accept_14,
- Accept_15,
- Accept_16,
- Accept_17,
- Accept_18,
- null,
- Accept_20,
- Accept_21,
- Accept_22,
- Accept_23,
- null,
- Accept_25,
- Accept_26,
- Accept_27,
- Accept_28,
- null,
- Accept_30,
- Accept_31,
- Accept_32,
- null,
- Accept_34,
- Accept_35,
- null,
- Accept_37,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- Accept_53,
- Accept_54,
- Accept_55,
- Accept_56,
- Accept_57,
- Accept_58,
- Accept_59,
- Accept_60,
- Accept_61,
- Accept_62,
- Accept_63,
- Accept_64,
- Accept_65,
- Accept_66,
- Accept_67,
- Accept_68,
- Accept_69,
- Accept_70,
- Accept_71,
- Accept_72,
- Accept_73,
- Accept_74,
- Accept_75,
- Accept_76,
- Accept_77,
- Accept_78,
- Accept_79,
- Accept_80,
- Accept_81,
- Accept_82,
- Accept_83,
- new AcceptMethod(Accept_84),
- };
+ {
+ null,
+ null,
+ Accept_2,
+ Accept_3,
+ Accept_4,
+ Accept_5,
+ Accept_6,
+ Accept_7,
+ Accept_8,
+ Accept_9,
+ Accept_10,
+ Accept_11,
+ Accept_12,
+ Accept_13,
+ Accept_14,
+ Accept_15,
+ Accept_16,
+ Accept_17,
+ Accept_18,
+ null,
+ Accept_20,
+ Accept_21,
+ Accept_22,
+ Accept_23,
+ null,
+ Accept_25,
+ Accept_26,
+ Accept_27,
+ Accept_28,
+ null,
+ Accept_30,
+ Accept_31,
+ Accept_32,
+ null,
+ Accept_34,
+ Accept_35,
+ null,
+ Accept_37,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ Accept_53,
+ Accept_54,
+ Accept_55,
+ Accept_56,
+ Accept_57,
+ Accept_58,
+ Accept_59,
+ Accept_60,
+ Accept_61,
+ Accept_62,
+ Accept_63,
+ Accept_64,
+ Accept_65,
+ Accept_66,
+ Accept_67,
+ Accept_68,
+ Accept_69,
+ Accept_70,
+ Accept_71,
+ Accept_72,
+ Accept_73,
+ Accept_74,
+ Accept_75,
+ Accept_76,
+ Accept_77,
+ Accept_78,
+ Accept_79,
+ Accept_80,
+ Accept_81,
+ Accept_82,
+ Accept_83,
+ new AcceptMethod(Accept_84),
+ };
}
private Token Accept_2()
@@ -802,9 +802,9 @@ private Token Accept_84()
private const int YYINITIAL = 0;
private static readonly int[] yy_state_dtrans = new[]
- {
- 0
- };
+ {
+ 0
+ };
private void yybegin(int state)
{
@@ -953,10 +953,10 @@ private char[] yy_double(char[] buf)
private const int YY_E_MATCH = 1;
private static string[] yy_error_string = new[]
- {
- "Error: Internal error.\n",
- "Error: Unmatched input.\n"
- };
+ {
+ "Error: Internal error.\n",
+ "Error: Unmatched input.\n"
+ };
private void yy_error(int code, bool fatal)
{
@@ -968,693 +968,693 @@ private void yy_error(int code, bool fatal)
}
private static readonly int[] yy_acpt = new[]
- {
- /* 0 */ YY_NOT_ACCEPT,
- /* 1 */ YY_NO_ANCHOR,
- /* 2 */ YY_NO_ANCHOR,
- /* 3 */ YY_NO_ANCHOR,
- /* 4 */ YY_NO_ANCHOR,
- /* 5 */ YY_NO_ANCHOR,
- /* 6 */ YY_NO_ANCHOR,
- /* 7 */ YY_NO_ANCHOR,
- /* 8 */ YY_NO_ANCHOR,
- /* 9 */ YY_NO_ANCHOR,
- /* 10 */ YY_NO_ANCHOR,
- /* 11 */ YY_NO_ANCHOR,
- /* 12 */ YY_NO_ANCHOR,
- /* 13 */ YY_END,
- /* 14 */ YY_NO_ANCHOR,
- /* 15 */ YY_NO_ANCHOR,
- /* 16 */ YY_NO_ANCHOR,
- /* 17 */ YY_NO_ANCHOR,
- /* 18 */ YY_NO_ANCHOR,
- /* 19 */ YY_NOT_ACCEPT,
- /* 20 */ YY_NO_ANCHOR,
- /* 21 */ YY_NO_ANCHOR,
- /* 22 */ YY_NO_ANCHOR,
- /* 23 */ YY_NO_ANCHOR,
- /* 24 */ YY_NOT_ACCEPT,
- /* 25 */ YY_NO_ANCHOR,
- /* 26 */ YY_NO_ANCHOR,
- /* 27 */ YY_NO_ANCHOR,
- /* 28 */ YY_NO_ANCHOR,
- /* 29 */ YY_NOT_ACCEPT,
- /* 30 */ YY_NO_ANCHOR,
- /* 31 */ YY_NO_ANCHOR,
- /* 32 */ YY_NO_ANCHOR,
- /* 33 */ YY_NOT_ACCEPT,
- /* 34 */ YY_NO_ANCHOR,
- /* 35 */ YY_NO_ANCHOR,
- /* 36 */ YY_NOT_ACCEPT,
- /* 37 */ YY_NO_ANCHOR,
- /* 38 */ YY_NOT_ACCEPT,
- /* 39 */ YY_NOT_ACCEPT,
- /* 40 */ YY_NOT_ACCEPT,
- /* 41 */ YY_NOT_ACCEPT,
- /* 42 */ YY_NOT_ACCEPT,
- /* 43 */ YY_NOT_ACCEPT,
- /* 44 */ YY_NOT_ACCEPT,
- /* 45 */ YY_NOT_ACCEPT,
- /* 46 */ YY_NOT_ACCEPT,
- /* 47 */ YY_NOT_ACCEPT,
- /* 48 */ YY_NOT_ACCEPT,
- /* 49 */ YY_NOT_ACCEPT,
- /* 50 */ YY_NOT_ACCEPT,
- /* 51 */ YY_NOT_ACCEPT,
- /* 52 */ YY_NOT_ACCEPT,
- /* 53 */ YY_NO_ANCHOR,
- /* 54 */ YY_NO_ANCHOR,
- /* 55 */ YY_NO_ANCHOR,
- /* 56 */ YY_NO_ANCHOR,
- /* 57 */ YY_NO_ANCHOR,
- /* 58 */ YY_NO_ANCHOR,
- /* 59 */ YY_NO_ANCHOR,
- /* 60 */ YY_NO_ANCHOR,
- /* 61 */ YY_NO_ANCHOR,
- /* 62 */ YY_NO_ANCHOR,
- /* 63 */ YY_NO_ANCHOR,
- /* 64 */ YY_NO_ANCHOR,
- /* 65 */ YY_NO_ANCHOR,
- /* 66 */ YY_NO_ANCHOR,
- /* 67 */ YY_NO_ANCHOR,
- /* 68 */ YY_NO_ANCHOR,
- /* 69 */ YY_NO_ANCHOR,
- /* 70 */ YY_NO_ANCHOR,
- /* 71 */ YY_NO_ANCHOR,
- /* 72 */ YY_NO_ANCHOR,
- /* 73 */ YY_NO_ANCHOR,
- /* 74 */ YY_NO_ANCHOR,
- /* 75 */ YY_NO_ANCHOR,
- /* 76 */ YY_NO_ANCHOR,
- /* 77 */ YY_NO_ANCHOR,
- /* 78 */ YY_NO_ANCHOR,
- /* 79 */ YY_NO_ANCHOR,
- /* 80 */ YY_NO_ANCHOR,
- /* 81 */ YY_NO_ANCHOR,
- /* 82 */ YY_NO_ANCHOR,
- /* 83 */ YY_NO_ANCHOR,
- /* 84 */ YY_NO_ANCHOR
- };
+ {
+ /* 0 */ YY_NOT_ACCEPT,
+ /* 1 */ YY_NO_ANCHOR,
+ /* 2 */ YY_NO_ANCHOR,
+ /* 3 */ YY_NO_ANCHOR,
+ /* 4 */ YY_NO_ANCHOR,
+ /* 5 */ YY_NO_ANCHOR,
+ /* 6 */ YY_NO_ANCHOR,
+ /* 7 */ YY_NO_ANCHOR,
+ /* 8 */ YY_NO_ANCHOR,
+ /* 9 */ YY_NO_ANCHOR,
+ /* 10 */ YY_NO_ANCHOR,
+ /* 11 */ YY_NO_ANCHOR,
+ /* 12 */ YY_NO_ANCHOR,
+ /* 13 */ YY_END,
+ /* 14 */ YY_NO_ANCHOR,
+ /* 15 */ YY_NO_ANCHOR,
+ /* 16 */ YY_NO_ANCHOR,
+ /* 17 */ YY_NO_ANCHOR,
+ /* 18 */ YY_NO_ANCHOR,
+ /* 19 */ YY_NOT_ACCEPT,
+ /* 20 */ YY_NO_ANCHOR,
+ /* 21 */ YY_NO_ANCHOR,
+ /* 22 */ YY_NO_ANCHOR,
+ /* 23 */ YY_NO_ANCHOR,
+ /* 24 */ YY_NOT_ACCEPT,
+ /* 25 */ YY_NO_ANCHOR,
+ /* 26 */ YY_NO_ANCHOR,
+ /* 27 */ YY_NO_ANCHOR,
+ /* 28 */ YY_NO_ANCHOR,
+ /* 29 */ YY_NOT_ACCEPT,
+ /* 30 */ YY_NO_ANCHOR,
+ /* 31 */ YY_NO_ANCHOR,
+ /* 32 */ YY_NO_ANCHOR,
+ /* 33 */ YY_NOT_ACCEPT,
+ /* 34 */ YY_NO_ANCHOR,
+ /* 35 */ YY_NO_ANCHOR,
+ /* 36 */ YY_NOT_ACCEPT,
+ /* 37 */ YY_NO_ANCHOR,
+ /* 38 */ YY_NOT_ACCEPT,
+ /* 39 */ YY_NOT_ACCEPT,
+ /* 40 */ YY_NOT_ACCEPT,
+ /* 41 */ YY_NOT_ACCEPT,
+ /* 42 */ YY_NOT_ACCEPT,
+ /* 43 */ YY_NOT_ACCEPT,
+ /* 44 */ YY_NOT_ACCEPT,
+ /* 45 */ YY_NOT_ACCEPT,
+ /* 46 */ YY_NOT_ACCEPT,
+ /* 47 */ YY_NOT_ACCEPT,
+ /* 48 */ YY_NOT_ACCEPT,
+ /* 49 */ YY_NOT_ACCEPT,
+ /* 50 */ YY_NOT_ACCEPT,
+ /* 51 */ YY_NOT_ACCEPT,
+ /* 52 */ YY_NOT_ACCEPT,
+ /* 53 */ YY_NO_ANCHOR,
+ /* 54 */ YY_NO_ANCHOR,
+ /* 55 */ YY_NO_ANCHOR,
+ /* 56 */ YY_NO_ANCHOR,
+ /* 57 */ YY_NO_ANCHOR,
+ /* 58 */ YY_NO_ANCHOR,
+ /* 59 */ YY_NO_ANCHOR,
+ /* 60 */ YY_NO_ANCHOR,
+ /* 61 */ YY_NO_ANCHOR,
+ /* 62 */ YY_NO_ANCHOR,
+ /* 63 */ YY_NO_ANCHOR,
+ /* 64 */ YY_NO_ANCHOR,
+ /* 65 */ YY_NO_ANCHOR,
+ /* 66 */ YY_NO_ANCHOR,
+ /* 67 */ YY_NO_ANCHOR,
+ /* 68 */ YY_NO_ANCHOR,
+ /* 69 */ YY_NO_ANCHOR,
+ /* 70 */ YY_NO_ANCHOR,
+ /* 71 */ YY_NO_ANCHOR,
+ /* 72 */ YY_NO_ANCHOR,
+ /* 73 */ YY_NO_ANCHOR,
+ /* 74 */ YY_NO_ANCHOR,
+ /* 75 */ YY_NO_ANCHOR,
+ /* 76 */ YY_NO_ANCHOR,
+ /* 77 */ YY_NO_ANCHOR,
+ /* 78 */ YY_NO_ANCHOR,
+ /* 79 */ YY_NO_ANCHOR,