├── .editorconfig
├── .gitattributes
├── .gitignore
├── .nuget
└── nuget.exe
├── Bitmap-MEDIUM_Entity-Framework-Core-Logo_2colors_Square_Boxed_RGB.png
├── EntityFramework.SqlServerCompact.sln
├── EntityFramework.SqlServerCompact.sln.DotSettings
├── LICENSE
├── NuGet.Config
├── NuGetBuild.cmd
├── README.md
├── key.snk
├── src
├── Provider35
│ ├── EntityFramework.SqlServerCompact35.csproj
│ ├── EntityFrameworkCore.SqlServerCompact35.nuspec
│ └── packages.config
└── Provider40
│ ├── Design
│ └── Internal
│ │ └── SqlCeDesignTimeServices.cs
│ ├── Diagnostics
│ ├── SqlCeEventId.cs
│ └── SqlCeStrings.cs
│ ├── EntityFramework.SqlServerCompact40.csproj
│ ├── EntityFrameworkCore.SqlServerCompact40.Core.nuspec
│ ├── EntityFrameworkCore.SqlServerCompact40.nuspec
│ ├── Extensions
│ ├── Logging
│ │ └── ConfigureLogging.cs
│ ├── SqlCeDatabaseFacadeExtensions.cs
│ ├── SqlCeDbContextOptionsExtensions.cs
│ ├── SqlCeMetaDataExtensions.cs
│ └── SqlCeServiceCollectionExtensions.cs
│ ├── Infrastructure
│ ├── Internal
│ │ ├── ISqlCeOptions.cs
│ │ └── SqlCeOptionsExtensions.cs
│ └── SqlCeDbContextOptionsBuilder.cs
│ ├── Internal
│ ├── SqlCeLoggerExtensions.cs
│ ├── SqlCeModelValidator.cs
│ └── SqlCeOptions.cs
│ ├── MetaData
│ ├── Conventions
│ │ └── Internal
│ │ │ └── SqlCeConventionSetBuilder.cs
│ └── Internal
│ │ ├── SqlCeAnnotationNames.cs
│ │ └── SqlCeInternalMetaDataBuilderExtensions.cs
│ ├── Migrations
│ ├── Internal
│ │ ├── SqlCeHistoryRepository.cs
│ │ └── SqlCeMigrationsAnnotationProvider.cs
│ └── SqlCeMigrationsSqlGenerator.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Query
│ ├── ExpressionTranslators
│ │ └── Internal
│ │ │ ├── SqlCeCompositeMemberTranslator.cs
│ │ │ ├── SqlCeCompositeMethodCallTranslator.cs
│ │ │ ├── SqlCeContainsOptimizedTranslator.cs
│ │ │ ├── SqlCeConvertTranslator.cs
│ │ │ ├── SqlCeDateAddTranslator.cs
│ │ │ ├── SqlCeDateDiffTranslator.cs
│ │ │ ├── SqlCeDateTimeDatePartComponentTranslator.cs
│ │ │ ├── SqlCeDateTimeNowTranslator.cs
│ │ │ ├── SqlCeEndsWithOptimizedTranslator.cs
│ │ │ ├── SqlCeMathTranslator.cs
│ │ │ ├── SqlCeNewGuidTranslator.cs
│ │ │ ├── SqlCeObjectToStringTranslator.cs
│ │ │ ├── SqlCeStartsWithOptimizedTranslator.cs
│ │ │ ├── SqlCeStringIndexOfTranslator.cs
│ │ │ ├── SqlCeStringIsNullOrWhiteSpaceTranslator.cs
│ │ │ ├── SqlCeStringLengthTranslator.cs
│ │ │ ├── SqlCeStringReplaceTranslator.cs
│ │ │ ├── SqlCeStringSubstringTranslator.cs
│ │ │ ├── SqlCeStringToLowerTranslator.cs
│ │ │ ├── SqlCeStringToUpperTranslator.cs
│ │ │ ├── SqlCeStringTrimEndTranslator.cs
│ │ │ ├── SqlCeStringTrimStartTranslator.cs
│ │ │ └── SqlCeStringTrimTranslator.cs
│ ├── ExpressionVisitors
│ │ ├── SqlCeTranslatingExpressionVisitor.cs
│ │ └── SqlCeTranslatingExpressionVisitorFactory.cs
│ ├── Expressions
│ │ └── Internal
│ │ │ └── DatePartExpression.cs
│ ├── Internal
│ │ ├── SqlCeQueryCompilationContext.cs
│ │ └── SqlCeQueryCompilationContextFactory.cs
│ └── Sql
│ │ └── Internal
│ │ ├── ISqlCeExpressionVisitor.cs
│ │ ├── SqlCeQuerySqlGenerator.cs
│ │ └── SqlCeQuerySqlGeneratorFactory.cs
│ ├── Scaffolding
│ └── Internal
│ │ ├── SqlCeCodeGenerator.cs
│ │ ├── SqlCeDatabaseModelfactory.cs
│ │ └── SqlDataReaderExtensions.cs
│ ├── SqlCeDbFunctionsExtensions.cs
│ ├── Storage
│ └── Internal
│ │ ├── ISqlCeDatabaseConnection.cs
│ │ ├── SqlCeByteArrayTypeMapping.cs
│ │ ├── SqlCeByteTypeMapping.cs
│ │ ├── SqlCeConnectionExtensions.cs
│ │ ├── SqlCeDatabaseConnection.cs
│ │ ├── SqlCeDatabaseCreator.cs
│ │ ├── SqlCeDateTimeTypeMapping.cs
│ │ ├── SqlCeDecimalTypeMapping.cs
│ │ ├── SqlCeDoubleTypeMapping.cs
│ │ ├── SqlCeFloatTypeMapping.cs
│ │ ├── SqlCeLongTypeMapping.cs
│ │ ├── SqlCeShortTypeMapping.cs
│ │ ├── SqlCeSqlGenerationHelper.cs
│ │ ├── SqlCeStringTypeMapping.cs
│ │ └── SqlCeTypeMapppingSource.cs
│ ├── Strings.Designer.cs
│ ├── Strings.resx
│ ├── Update
│ └── Internal
│ │ ├── ISqlCeUpdateSqlGenerator.cs
│ │ ├── SqlCeModificationCommandBatch.cs
│ │ ├── SqlCeModificationCommandBatchFactory.cs
│ │ └── SqlCeUpdateSqlGenerator.cs
│ ├── Utilities
│ ├── Check.cs
│ ├── CodeAnnotations.cs
│ ├── SharedTypeExtensions.cs
│ └── SqlCeHelper.cs
│ └── packages.config
├── test
├── EntityFramework.SqlServerCompact.FunctionalTests
│ ├── BasicEndToEndScenario.cs
│ ├── BasicEndToEndScenarioForIdentity.cs
│ ├── BasicEndToEndScenarioForNoIdentity.cs
│ ├── BuiltInDataTypesSqlCeTest.cs
│ ├── CompositeKeyEndToEndSqlCeTest.cs
│ ├── CompositeKeyEndToEndTest.cs
│ ├── ConcurrencyDetectorSqlCeTest.cs
│ ├── ConvertToProviderTypesSqlCeTest.cs
│ ├── CustomConvertersSqlCeTest.cs
│ ├── DataAnnotationSqlCeTest.cs
│ ├── DataBindingSqlCeTest.cs
│ ├── DbContextPoolingTest.cs
│ ├── DefaultValuesTest.cs
│ ├── EFCore.png
│ ├── EntityFramework.SqlServerCompact.FunctionalTests.csproj
│ ├── EverythingIsBytesSqlCeTest.cs
│ ├── EverythingIsStringsSqlCeTest.cs
│ ├── F1SqlCeFixture.cs
│ ├── FieldMappingSqlCeTest.cs
│ ├── FindSqlCeTest.cs
│ ├── GraphUpdateWithIdentitySqlCeTest.cs
│ ├── Issue305Test.cs
│ ├── Issue398Test.cs
│ ├── Issue541Test.cs
│ ├── LazyLoadProxySqlCeTest.cs
│ ├── LoadSqlCeTest.cs
│ ├── LoggingSqlCeTest.cs
│ ├── Migrations
│ │ ├── 20160215092248_Migration01.Designer.cs
│ │ ├── 20160215092248_Migration01.cs
│ │ ├── 20160215092329_Migration02.Designer.cs
│ │ ├── 20160215092329_Migration02.cs
│ │ ├── 20170129135547_MyFirstMigration.Designer.cs
│ │ ├── 20170129135547_MyFirstMigration.cs
│ │ ├── 20170129140932_MySecondMigration.Designer.cs
│ │ ├── 20170129140932_MySecondMigration.cs
│ │ ├── BloggingContextModelSnapshot.cs
│ │ └── TiffFilesContextModelSnapshot.cs
│ ├── MigrationsSqlCeFixture.cs
│ ├── MigrationsSqlCeTest.cs
│ ├── MonsterFixupChangedChangingSqlCeTest.cs
│ ├── NorthwindEF7.sdf
│ ├── NotificationEntitiesSqlCeTest.cs
│ ├── OptimisticConcurrencySqlCeTest.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── PropertyEntrySqlCeTest.cs
│ ├── PropertyValuesSqlCeTest.cs
│ ├── ProxyGraphUpdatesSqlCeTest.cs
│ ├── Query
│ │ ├── AsNoTrackingSqlCeTest.cs
│ │ ├── AsTrackingSqlCeTest.cs
│ │ ├── AsyncFromSqlQuerySqlCeTest.cs
│ │ ├── AsyncGearsOfWarSqlCeTest.cs
│ │ ├── AsyncGroupByQuerySqlCeTest.cs
│ │ ├── AsyncIncludeSqlCeTest.cs
│ │ ├── AsyncSimpleQuerySqlCeTest.cs
│ │ ├── ChangeTrackingSqlCeTest.cs
│ │ ├── CompiledQuerySqlCeTest.cs
│ │ ├── ComplexNavigationsQuerySqlCeFixture.cs
│ │ ├── ComplexNavigationsQuerySqlCeTest.cs
│ │ ├── ComplexNavigationsWeakQuerySqlCeFixture.cs
│ │ ├── ComplexNavigationsWeakQuerySqlCeTest.cs
│ │ ├── DbFunctionsSqlCeTest.cs
│ │ ├── FiltersInheritanceSqlCeFixture.cs
│ │ ├── FiltersInheritanceSqlCeTest.cs
│ │ ├── FiltersSqlCeTest.cs
│ │ ├── FromSqlQuerySqlCeTest.cs
│ │ ├── FunkyDataQuerySqlCeTest.cs
│ │ ├── GearsOfWarFromSqlQuerySqlCeTest.cs
│ │ ├── GearsOfWarQuerySqlCeFixture.cs
│ │ ├── GearsOfWarSqlCeTest.cs
│ │ ├── GroupBySqlCeTest.cs
│ │ ├── IncludeOneToOneSqlCeTest.cs
│ │ ├── IncludeSqlCeFixture.cs
│ │ ├── IncludeSqlCeTest.cs
│ │ ├── InheritanceRelationshipsQuerySqlCeFixture.cs
│ │ ├── InheritanceRelationshipsQuerySqlCeTest.cs
│ │ ├── InheritanceSqlCeFixture.cs
│ │ ├── InheritanceSqlCeTest.cs
│ │ ├── MappingQuerySqlCeTest.cs
│ │ ├── NavigationTest.cs
│ │ ├── NorthwindQuerySqlCeFixture.cs
│ │ ├── NorthwindQueryWithForcedClientEvalSqlCeFixture.cs
│ │ ├── NullKeysSqlCeTest.cs
│ │ ├── NullSemanticsQuerySqlCeFixture.cs
│ │ ├── NullSemanticsQuerySqlCeTest.cs
│ │ ├── OwnedQuerySqlCeTest.cs
│ │ ├── QueryFilterFuncletizationSqlCeTest.cs
│ │ ├── QueryNavigationsSqlCeTest.cs
│ │ ├── QueryNavigationsWithForcedClientEvalSqlCeTest.cs
│ │ ├── QueryNoClientEvalSqlCeFixture.cs
│ │ ├── QueryNoClientEvalSqlCeTest.cs
│ │ ├── QueryTaggingSqlCeTest.cs
│ │ └── SimpleQuerySqlCeTest.cs
│ ├── Scaffolding
│ │ ├── SqlCeDatabaseModelFactoryTest.cs
│ │ └── SqlCeDatabaseModelFixture.cs
│ ├── SqlCeCommandDisposeTest.cs
│ ├── SqlCeComplianceTest.cs
│ ├── SqlCeConfigPatternsTest.cs
│ ├── SqlCeDataStoreCreatorTest.cs
│ ├── SqlCeDatabaseCreationTest.cs
│ ├── SqlCeMigrationsSqlGeneratorTest.cs
│ ├── SqlCeMigrationsTest.cs
│ ├── SqlCeServiceCollectionExtensionsTest.cs
│ ├── StoreGeneratedFixUpSqlCeTest.cs
│ ├── StoreGeneratedSqlCeTest.cs
│ ├── TableSplittingSqlCeTest.cs
│ ├── TestUtilities
│ │ ├── DbContextOptionsBuilderExtensions.cs
│ │ ├── SqlCeDatabaseCleaner.cs
│ │ ├── SqlCeDatabaseFacadeTestExtensions.cs
│ │ ├── SqlCeNorthwindTestStoreFactory.cs
│ │ ├── SqlCeTestHelpers.cs
│ │ ├── SqlCeTestStore.cs
│ │ ├── SqlCeTestStoreFactorycs.cs
│ │ ├── SqlServerConditionAttribute.cs
│ │ └── TestEnvironment.cs
│ ├── TransactionSqlCetest.cs
│ ├── UpdatesSqlCeFixture.cs
│ ├── UpdatesSqlCeTest.cs
│ ├── WarningsSqlCeTest.cs
│ ├── WithConstructorsSqlCeTest.cs
│ ├── app.config
│ └── packages.config
├── EntityFramework.SqlServerCompact.Tests
│ ├── ApiConsistencyTest.cs
│ ├── ApiConsistencyTestBase.cs
│ ├── Design
│ │ ├── DesignTimeProvidersServicesTest.cs
│ │ └── SqlCeDesignTimeProviderServicesTest.cs
│ ├── EntityFramework.SqlServerCompact.Tests.csproj
│ ├── Extensions
│ │ ├── Metadata
│ │ │ ├── InternalSqlCeMetadataBuilderExtensionsTest.cs.cs
│ │ │ ├── SqlCeBuilderExtensionsTest.cs
│ │ │ └── SqlCeMetadataExtensionsTest.cs
│ │ └── SqlCeDbContextOptionsExtensionsTest.cs
│ ├── Migrations
│ │ ├── MigrationsModelDifferTestBase.cs
│ │ ├── SqlCeHistoryRepositoryTest.cs
│ │ ├── SqlCeMigrationSqlGeneratorTest.cs
│ │ └── SqlCeModelDifferTest.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RelationalModelValidatorTest.cs
│ ├── Scaffolding
│ │ └── SqlCeCodeGeneratorTest.cs
│ ├── SqlCeDataStoreConnectionTest.cs
│ ├── SqlCeDataStoreSourceTest.cs
│ ├── SqlCeDatabaseFacadeTest.cs
│ ├── SqlCeTestHelpers.cs
│ ├── SqlCeTypeMapperTest.cs
│ ├── Storage
│ │ ├── RelationalTypeMapperTestBase.cs
│ │ ├── RelationalTypeMappingTest.cs
│ │ ├── SqlCeSqlGenerationHelperTest.cs
│ │ ├── SqlCeTypeMappingTest.cs
│ │ └── SqlGenerationHelperTestBase.cs
│ ├── Utilities
│ │ ├── FakeInterceptingLogger.cs
│ │ ├── FakeProvider
│ │ │ ├── FakeCommandExecutor.cs
│ │ │ ├── FakeDbCommand.cs
│ │ │ ├── FakeDbConnection.cs
│ │ │ ├── FakeDbDataReader.cs
│ │ │ ├── FakeDbParameter.cs
│ │ │ ├── FakeDbParameterCollection.cs
│ │ │ ├── FakeDbTransaction.cs
│ │ │ ├── FakeRelationalConnection.cs
│ │ │ ├── FakeRelationalDatabaseCreator.cs
│ │ │ ├── FakeRelationalOptionsExtension.cs
│ │ │ └── FakeSqlGenerator.cs
│ │ ├── RelationalTestHelpers.cs
│ │ ├── TestModificationCommandBatchFactory.cs
│ │ ├── TestProviderCodeGenerator.cs
│ │ ├── TestQuerySqlGenerator.cs
│ │ ├── TestQuerySqlGeneratorFactory.cs
│ │ ├── TestRelationalCompositeMemberTranslator.cs
│ │ ├── TestRelationalCompositeMethodCallTranslator.cs
│ │ ├── TestRelationalConventionSetBuilder.cs
│ │ ├── TestRelationalMetadataExtensions.cs
│ │ ├── TestRelationalMigrationSqlGenerator.cs
│ │ └── TestRelationalTypeMappingSource.cs
│ ├── app.config
│ └── packages.config
└── EntityFramework.SqlServerCompact35.FunctionalTests
│ ├── EntityFramework.SqlServerCompact35.FunctionalTests.csproj
│ ├── NWforEF7.sqlce
│ ├── NorthwindEF735.sdf
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── app.config
│ └── packages.config
└── tools
├── SSCERuntime_x64-ENU.msi
└── SSCERuntime_x86-ENU.msi
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.nuget/nuget.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/.nuget/nuget.exe
--------------------------------------------------------------------------------
/Bitmap-MEDIUM_Entity-Framework-Core-Logo_2colors_Square_Boxed_RGB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/Bitmap-MEDIUM_Entity-Framework-Core-Logo_2colors_Square_Boxed_RGB.png
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/NuGetBuild.cmd:
--------------------------------------------------------------------------------
1 | .nuget\nuget pack .\src\design35\EntityFrameworkCore.SqlServerCompact35.Design.nuspec -version 1.1.0-preview1-final
2 | .nuget\nuget pack .\src\provider35\EntityFrameworkCore.SqlServerCompact35.nuspec -version 1.1.0-preview1-final
3 |
4 | .nuget\nuget pack .\src\design40\EntityFrameworkCore.SqlServerCompact40.Design.nuspec -version 1.1.0-preview1-final
5 | .nuget\nuget pack .\src\provider40\EntityFrameworkCore.SqlServerCompact40.nuspec -version 1.1.0-preview1-final
6 |
7 | pause
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # EntityFrameworkCore.SqlServerCompact
2 | This project is the Entity Framework Core SQL Server Compact providers for SQL Server Compact 4.0 and 3.5 SP2.
3 |
4 | This project is archived, as SQL Server Compact is out of support.
5 |
6 | [](https://ci.appveyor.com/project/ErikEJ/entityframework-sqlservercompact/branch/master)
7 |
8 | This provider is mainly intended for desktop applications under .NET 4.6.1 (Console, WPF, WinForms and Services), but may also work under ASP.NET 4.6.1 and ASP.NET Core 2.0 when using the full .NET Framework runtime. It does **not** work under the .NET Core runtime.
9 |
10 | See the [Wiki pages](https://github.com/ErikEJ/EntityFramework.SqlServerCompact/wiki) for information on how to get started with the source code and the NuGet package.
11 |
12 | You can find the latest build on the [MyGet feed](https://www.myget.org/gallery/ef7-sqlce)
13 |
14 | Testing, comments, questions, pull requests are most welcome!
15 |
--------------------------------------------------------------------------------
/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/key.snk
--------------------------------------------------------------------------------
/src/Provider35/EntityFrameworkCore.SqlServerCompact35.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EntityFrameworkCore.SqlServerCompact35
5 | $version$
6 | EntityFrameworkCore.SqlServerCompact35
7 | ErikEJ
8 | ErikEJ
9 | https://github.com/ErikEJ/EntityFramework.SqlServerCompact
10 | false
11 | Allows SQL Server Compact 3.5 SP2 to be used with Entity Framework Core. Requires the SQL Server Compact 3.5 SP2 runtime to be installed
12 | Allows SQL Server Compact 3.5 SP2 to be used with Entity Framework Core
13 | for EF Core 2.2.0
14 | EntityFramework EF sqlce sqlservercompact entity framework core provider sql server compact entityframeworkcore efcore
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Provider35/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/Provider40/Design/Internal/SqlCeDesignTimeServices.cs:
--------------------------------------------------------------------------------
1 | using EFCore.SqlCe.Scaffolding.Internal;
2 | using EFCore.SqlCe.Storage.Internal;
3 | using Microsoft.EntityFrameworkCore.Design;
4 | using Microsoft.EntityFrameworkCore.Scaffolding;
5 | using Microsoft.EntityFrameworkCore.Storage;
6 | using Microsoft.Extensions.DependencyInjection;
7 |
8 | namespace EFCore.SqlCe.Design.Internal
9 | {
10 | public class SqlCeDesignTimeServices : IDesignTimeServices
11 | {
12 | public virtual void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
13 | => serviceCollection
14 | .AddSingleton()
15 | .AddSingleton()
16 | .AddSingleton()
17 | .AddSingleton();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Provider40/EntityFrameworkCore.SqlServerCompact40.Core.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EntityFrameworkCore.SqlServerCompact40.Core
5 | $version$
6 | EntityFrameworkCore.SqlServerCompact40.Core
7 | ErikEJ
8 | ErikEJ
9 | https://github.com/ErikEJ/EntityFramework.SqlServerCompact
10 | false
11 | Allows SQL Server Compact 4.0 to be used with Entity Framework Core. Requires the SQL Server Compact 4.0 runtime to be installed
12 | Allows SQL Server Compact 4.0 to be used with Entity Framework Core
13 | for EF Core 2.2.0
14 | EntityFramework EF sqlce entity framework core provider sql server compact sqlservercompact entityframeworkcore efcore
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Provider40/EntityFrameworkCore.SqlServerCompact40.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EntityFrameworkCore.SqlServerCompact40
5 | $version$
6 | EntityFrameworkCore.SqlServerCompact40
7 | ErikEJ
8 | ErikEJ
9 | https://github.com/ErikEJ/EntityFramework.SqlServerCompact
10 | false
11 | Allows SQL Server Compact 4.0 to be used with Entity Framework Core
12 | Allows SQL Server Compact 4.0 to be used with Entity Framework Core
13 | for EF Core 2.2.0
14 | EntityFramework EF sqlce entity framework core provider sql server compact sqlservercompact entityframeworkcore efcore
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Provider40/Extensions/SqlCeDatabaseFacadeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using EFCore.SqlCe.Infrastructure.Internal;
4 | using JetBrains.Annotations;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 |
7 | // ReSharper disable once CheckNamespace
8 |
9 | namespace Microsoft.EntityFrameworkCore
10 | {
11 | public static class SqlCeDatabaseFacadeExtensions
12 | {
13 | ///
14 | ///
15 | /// Returns true if the database provider currently in use is the SQL Server Compact provider.
16 | ///
17 | ///
18 | /// This method can only be used after the has been configured because
19 | /// it is only then that the provider is known. This means that this method cannot be used
20 | /// in because this is where application code sets the
21 | /// provider to use as part of configuring the context.
22 | ///
23 | ///
24 | /// The facade from .
25 | /// True if SQL Compact is being used; false otherwise.
26 | public static bool IsSqlCe([NotNull] this DatabaseFacade database)
27 | => database.ProviderName.Equals(
28 | typeof(SqlCeOptionsExtension).GetTypeInfo().Assembly.GetName().Name,
29 | StringComparison.Ordinal);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Provider40/Infrastructure/Internal/ISqlCeOptions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 |
3 | namespace EFCore.SqlCe.Infrastructure.Internal
4 | {
5 | ///
6 | /// Options set at the singleton level to control SqlServer specific options.
7 | ///
8 | public interface ISqlCeOptions : ISingletonOptions
9 | {
10 | ///
11 | /// Reflects the option set by .
12 | ///
13 | bool ClientEvalForUnsupportedSqlConstructs { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Provider40/Infrastructure/SqlCeDbContextOptionsBuilder.cs:
--------------------------------------------------------------------------------
1 | using EFCore.SqlCe.Infrastructure.Internal;
2 | using JetBrains.Annotations;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Infrastructure
5 | {
6 | ///
7 | ///
8 | /// Allows SQL Server Compact specific configuration to be performed on .
9 | ///
10 | ///
11 | /// Instances of this class are returned from a call to
12 | ///
13 | /// and it is not designed to be directly constructed in your application code.
14 | ///
15 | ///
16 | public class SqlCeDbContextOptionsBuilder
17 | : RelationalDbContextOptionsBuilder
18 | {
19 | ///
20 | /// Initializes a new instance of the class.
21 | ///
22 | /// The options builder.
23 | public SqlCeDbContextOptionsBuilder([NotNull] DbContextOptionsBuilder optionsBuilder)
24 | : base(optionsBuilder)
25 | {
26 | }
27 |
28 | ///
29 | /// Use forced client evalution for queries generated by the built-in Relational SQL generator,
30 | ///that are not supported by SQL Server Compact - nested SELECTs in ORDER BY for example
31 | ///
32 | public virtual void UseClientEvalForUnsupportedSqlConstructs(bool clientEvalForUnsupportedSqlConstructs = false)
33 | => WithOption(e => e.WithClientEvalForUnsupportedSqlConstructs(clientEvalForUnsupportedSqlConstructs));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Provider40/Internal/SqlCeModelValidator.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using JetBrains.Annotations;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.Metadata;
6 |
7 | namespace EFCore.SqlCe.Internal
8 | {
9 | public class SqlCeModelValidator : RelationalModelValidator
10 | {
11 | public SqlCeModelValidator(
12 | [NotNull] ModelValidatorDependencies dependencies,
13 | [NotNull] RelationalModelValidatorDependencies relationalDependencies)
14 | : base(dependencies, relationalDependencies)
15 | {
16 | }
17 |
18 | public override void Validate(IModel model)
19 | {
20 | base.Validate(model);
21 |
22 | ValidateNoSchemas(model);
23 | ValidateNoSequences(model);
24 | }
25 |
26 | protected virtual void ValidateNoSchemas([NotNull] IModel model)
27 | {
28 | foreach (var entityType in model.GetEntityTypes().Where(e => e.Relational().Schema != null))
29 | {
30 | Dependencies.Logger.SchemaConfiguredWarning(entityType, entityType.Relational().Schema);
31 | }
32 | }
33 |
34 | protected virtual void ValidateNoSequences([NotNull] IModel model)
35 | {
36 | foreach (var sequence in model.Relational().Sequences)
37 | {
38 | Dependencies.Logger.SequenceConfiguredWarning(sequence);
39 | }
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/Provider40/Internal/SqlCeOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EFCore.SqlCe.Infrastructure.Internal;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 |
6 | namespace EFCore.SqlCe.Internal
7 | {
8 | ///
9 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
10 | /// directly from your code. This API may change or be removed in future releases.
11 | ///
12 | public class SqlCeOptions : ISqlCeOptions
13 | {
14 | ///
15 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
16 | /// directly from your code. This API may change or be removed in future releases.
17 | ///
18 | public virtual void Initialize(IDbContextOptions options)
19 | {
20 | var sqlCeOptions = options.FindExtension() ?? new SqlCeOptionsExtension();
21 |
22 | ClientEvalForUnsupportedSqlConstructs = sqlCeOptions.ClientEvalForUnsupportedSqlConstructs ?? false;
23 | }
24 |
25 | ///
26 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
27 | /// directly from your code. This API may change or be removed in future releases.
28 | ///
29 | public virtual void Validate(IDbContextOptions options)
30 | {
31 | var sqlCeOptions = options.FindExtension() ?? new SqlCeOptionsExtension();
32 |
33 | if (ClientEvalForUnsupportedSqlConstructs != (sqlCeOptions.ClientEvalForUnsupportedSqlConstructs ?? false))
34 | {
35 | throw new InvalidOperationException(
36 | $"A call was made to '{nameof(SqlCeDbContextOptionsBuilder.UseClientEvalForUnsupportedSqlConstructs)}' that changed an option that must be constant within a service provider, but Entity Framework is not building its own internal service provider. Either allow EF to build the service provider by removing the call to '{nameof(DbContextOptionsBuilder.UseInternalServiceProvider)}', or ensure that the configuration for '{nameof(SqlCeDbContextOptionsBuilder.UseClientEvalForUnsupportedSqlConstructs)}' does not change for all uses of a given service provider passed to '{nameof(DbContextOptionsBuilder.UseInternalServiceProvider)}'.");
37 | }
38 | }
39 |
40 | ///
41 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
42 | /// directly from your code. This API may change or be removed in future releases.
43 | ///
44 | public virtual bool ClientEvalForUnsupportedSqlConstructs { get; private set; }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Provider40/MetaData/Conventions/Internal/SqlCeConventionSetBuilder.cs:
--------------------------------------------------------------------------------
1 | using JetBrains.Annotations;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Metadata.Conventions;
4 | using Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal;
5 | using Microsoft.EntityFrameworkCore.Storage;
6 | using Microsoft.EntityFrameworkCore.Utilities;
7 | using Microsoft.Extensions.DependencyInjection;
8 |
9 | namespace EFCore.SqlCe.Metadata.Conventions.Internal
10 | {
11 | public class SqlCeConventionSetBuilder : RelationalConventionSetBuilder
12 | {
13 | public SqlCeConventionSetBuilder(
14 | [NotNull] RelationalConventionSetBuilderDependencies dependencies,
15 | [NotNull] ISqlGenerationHelper sqlGenerationHelper)
16 | : base(dependencies)
17 | {
18 | }
19 |
20 | public override ConventionSet AddConventions(ConventionSet conventionSet)
21 | {
22 | Check.NotNull(conventionSet, nameof(conventionSet));
23 |
24 | base.AddConventions(conventionSet);
25 |
26 | conventionSet.ModelInitializedConventions.Add(new RelationalMaxIdentifierLengthConvention(128));
27 |
28 | return conventionSet;
29 | }
30 |
31 | public static ConventionSet Build()
32 | {
33 | var serviceProvider = new ServiceCollection()
34 | .AddEntityFrameworkSqlCe()
35 | .AddDbContext(o => o.UseSqlCe("Data Source=_.sdf"))
36 | .BuildServiceProvider();
37 |
38 | using (var serviceScope = serviceProvider.GetRequiredService().CreateScope())
39 | {
40 | using (var context = serviceScope.ServiceProvider.GetService())
41 | {
42 | return ConventionSet.CreateConventionSet(context);
43 | }
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Provider40/MetaData/Internal/SqlCeAnnotationNames.cs:
--------------------------------------------------------------------------------
1 | namespace EFCore.SqlCe.Metadata.Internal
2 | {
3 | public static class SqlCeAnnotationNames
4 | {
5 | public const string ValueGeneration = "SqlCe:ValueGeneration";
6 | public const string Identity = "True";
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/Provider40/MetaData/Internal/SqlCeInternalMetaDataBuilderExtensions.cs:
--------------------------------------------------------------------------------
1 | using JetBrains.Annotations;
2 | using Microsoft.EntityFrameworkCore.Metadata.Internal;
3 |
4 | namespace EFCore.SqlCe.Metadata.Internal
5 | {
6 | public static class SqlCeInternalMetadataBuilderExtensions
7 | {
8 | public static RelationalModelBuilderAnnotations SqlCe(
9 | [NotNull] this InternalModelBuilder builder,
10 | ConfigurationSource configurationSource)
11 | => new RelationalModelBuilderAnnotations(builder, configurationSource);
12 |
13 | public static RelationalPropertyBuilderAnnotations SqlCe(
14 | [NotNull] this InternalPropertyBuilder builder,
15 | ConfigurationSource configurationSource)
16 | => new RelationalPropertyBuilderAnnotations(builder, configurationSource);
17 |
18 | public static RelationalEntityTypeBuilderAnnotations SqlCe(
19 | [NotNull] this InternalEntityTypeBuilder builder,
20 | ConfigurationSource configurationSource)
21 | => new RelationalEntityTypeBuilderAnnotations(builder, configurationSource);
22 |
23 | public static RelationalKeyBuilderAnnotations SqlCe(
24 | [NotNull] this InternalKeyBuilder builder,
25 | ConfigurationSource configurationSource)
26 | => new RelationalKeyBuilderAnnotations(builder, configurationSource);
27 |
28 | public static RelationalIndexBuilderAnnotations SqlCe(
29 | [NotNull] this InternalIndexBuilder builder,
30 | ConfigurationSource configurationSource)
31 | => new RelationalIndexBuilderAnnotations(builder, configurationSource);
32 |
33 | public static RelationalForeignKeyBuilderAnnotations SqlCe(
34 | [NotNull] this InternalRelationshipBuilder builder,
35 | ConfigurationSource configurationSource)
36 | => new RelationalForeignKeyBuilderAnnotations(builder, configurationSource);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Provider40/Migrations/Internal/SqlCeHistoryRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using JetBrains.Annotations;
3 | using Microsoft.EntityFrameworkCore.Migrations;
4 |
5 | namespace EFCore.SqlCe.Migrations.Internal
6 | {
7 | public class SqlCeHistoryRepository : HistoryRepository
8 | {
9 | public SqlCeHistoryRepository([NotNull] HistoryRepositoryDependencies dependencies)
10 | : base(dependencies)
11 | {
12 | }
13 |
14 | protected override string ExistsSql
15 | {
16 | get
17 | {
18 | var stringTypeMapping = Dependencies.TypeMappingSource.FindMapping(typeof(string));
19 |
20 | return "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = " +
21 | stringTypeMapping.GenerateSqlLiteral(
22 | SqlGenerationHelper.DelimitIdentifier(TableName)) +
23 | " AND TABLE_TYPE <> N'SYSTEM TABLE'";
24 | }
25 | }
26 |
27 | protected override bool InterpretExistsResult(object value) => value != DBNull.Value;
28 |
29 | public override string GetCreateIfNotExistsScript() => GetCreateScript();
30 |
31 | public override string GetBeginIfNotExistsScript(string migrationId)
32 | {
33 | throw new NotSupportedException("Generating idempotent scripts for migration is not currently supported by SQL Server Compact");
34 | }
35 |
36 | public override string GetBeginIfExistsScript(string migrationId)
37 | {
38 | throw new NotSupportedException("Generating idempotent scripts for migration is not currently supported by SQL Server Compact");
39 | }
40 |
41 | public override string GetEndIfScript()
42 | {
43 | throw new NotSupportedException("Generating idempotent scripts for migration is not currently supported by SQL Server Compact");
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Provider40/Migrations/Internal/SqlCeMigrationsAnnotationProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using EFCore.SqlCe.Metadata.Internal;
4 | using JetBrains.Annotations;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 | using Microsoft.EntityFrameworkCore.Metadata;
7 | using Microsoft.EntityFrameworkCore.Migrations;
8 |
9 | namespace EFCore.SqlCe.Migrations.Internal
10 | {
11 | public class SqlCeMigrationsAnnotationProvider : MigrationsAnnotationProvider
12 | {
13 | public SqlCeMigrationsAnnotationProvider([NotNull] MigrationsAnnotationProviderDependencies dependencies)
14 | : base(dependencies)
15 | {
16 | }
17 |
18 | public override IEnumerable For(IProperty property)
19 | {
20 | var generateIdentityKey = (property.ValueGenerated == ValueGenerated.OnAdd)
21 | && property.ClrType.IsIntegerForIdentity();
22 |
23 | if (generateIdentityKey)
24 | {
25 | yield return new Annotation(
26 | SqlCeAnnotationNames.ValueGeneration,
27 | SqlCeAnnotationNames.Identity);
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Provider40/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using Microsoft.EntityFrameworkCore.Design;
3 |
4 | [assembly: DesignTimeProviderServices("EFCore.SqlCe.Design.Internal.SqlCeDesignTimeServices")]
5 | #if SQLCE35
6 | [assembly: AssemblyTitle("EntityFrameworkCore.SqlServerCompact35")]
7 | [assembly: AssemblyProduct("EntityFrameworkCore.SqlServerCompact35")]
8 | #else
9 | [assembly: AssemblyTitle("EntityFrameworkCore.SqlServerCompact40")]
10 | [assembly: AssemblyProduct("EntityFrameworkCore.SqlServerCompact40")]
11 | #endif
12 | [assembly: AssemblyVersion("2.1.0.0")]
13 | [assembly: AssemblyFileVersion("2.1.0.0")]
14 | [assembly: AssemblyInformationalVersion("2.1.0-rtm")]
15 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeCompositeMemberTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using JetBrains.Annotations;
3 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
4 |
5 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
6 | {
7 | public class SqlCeCompositeMemberTranslator : RelationalCompositeMemberTranslator
8 | {
9 | public SqlCeCompositeMemberTranslator([NotNull] RelationalCompositeMemberTranslatorDependencies dependencies)
10 | : base(dependencies)
11 | {
12 | var sqlCeTranslators = new List
13 | {
14 | new SqlCeStringLengthTranslator(),
15 | new SqlCeDateTimeNowTranslator(),
16 | new SqlCeDateTimeDatePartComponentTranslator(),
17 | };
18 |
19 | // ReSharper disable once VirtualMemberCallInContructor
20 | AddTranslators(sqlCeTranslators);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeCompositeMethodCallTranslator.cs:
--------------------------------------------------------------------------------
1 | using JetBrains.Annotations;
2 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
3 |
4 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
5 | {
6 | public class SqlCeCompositeMethodCallTranslator : RelationalCompositeMethodCallTranslator
7 | {
8 | private static readonly IMethodCallTranslator[] _methodCallTranslators =
9 | {
10 | new SqlCeContainsOptimizedTranslator(),
11 | new SqlCeConvertTranslator(),
12 | new SqlCeDateAddTranslator(),
13 | new SqlCeDateDiffTranslator(),
14 | new SqlCeEndsWithOptimizedTranslator(),
15 | new SqlCeMathTranslator(),
16 | new SqlCeNewGuidTranslator(),
17 | new SqlCeObjectToStringTranslator(),
18 | new SqlCeStartsWithOptimizedTranslator(),
19 | new SqlCeStringIsNullOrWhiteSpaceTranslator(),
20 | new SqlCeStringReplaceTranslator(),
21 | new SqlCeStringSubstringTranslator(),
22 | new SqlCeStringToLowerTranslator(),
23 | new SqlCeStringToUpperTranslator(),
24 | new SqlCeStringTrimEndTranslator(),
25 | new SqlCeStringTrimStartTranslator(),
26 | new SqlCeStringTrimTranslator(),
27 | new SqlCeStringIndexOfTranslator()
28 | };
29 |
30 | public SqlCeCompositeMethodCallTranslator(
31 | [NotNull] RelationalCompositeMethodCallTranslatorDependencies dependencies)
32 | : base(dependencies)
33 | {
34 | // ReSharper disable once DoNotCallOverridableMethodsInConstructor
35 | AddTranslators(_methodCallTranslators);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeContainsOptimizedTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Linq.Expressions;
2 | using System.Reflection;
3 | using Microsoft.EntityFrameworkCore.Query.Expressions;
4 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
5 |
6 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
7 | {
8 | ///
9 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
10 | /// directly from your code. This API may change or be removed in future releases.
11 | ///
12 | public class SqlCeContainsOptimizedTranslator : IMethodCallTranslator
13 | {
14 | private static readonly MethodInfo _methodInfo
15 | = typeof(string).GetRuntimeMethod(nameof(string.Contains), new[] { typeof(string) });
16 |
17 | public virtual Expression Translate(MethodCallExpression methodCallExpression)
18 | {
19 | if (Equals(methodCallExpression.Method, _methodInfo))
20 | {
21 | var patternExpression = methodCallExpression.Arguments[0];
22 | var patternConstantExpression = patternExpression as ConstantExpression;
23 |
24 | var charIndexExpression = Expression.GreaterThan(
25 | new SqlFunctionExpression("CHARINDEX", typeof(int), new[] { patternExpression, methodCallExpression.Object }),
26 | Expression.Constant(0));
27 |
28 | return
29 | patternConstantExpression != null
30 | ? (string)patternConstantExpression.Value == string.Empty
31 | ? (Expression)Expression.Constant(true)
32 | : charIndexExpression
33 | : Expression.OrElse(
34 | charIndexExpression,
35 | Expression.Equal(patternExpression, Expression.Constant(string.Empty)));
36 | }
37 |
38 | return null;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeDateTimeDatePartComponentTranslator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using EFCore.SqlCe.Query.Expressions.Internal;
4 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
5 |
6 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
7 | {
8 | public class SqlCeDateTimeDatePartComponentTranslator : IMemberTranslator
9 | {
10 | public virtual Expression Translate(MemberExpression memberExpression)
11 | {
12 | string datePart;
13 | if ((memberExpression.Expression != null)
14 | && (memberExpression.Expression.Type == typeof(DateTime))
15 | && ((datePart = GetDatePart(memberExpression.Member.Name)) != null))
16 | {
17 | return new DatePartExpression(datePart,
18 | memberExpression.Type,
19 | memberExpression.Expression);
20 | }
21 | return null;
22 | }
23 |
24 | private static string GetDatePart(string memberName)
25 | {
26 | switch (memberName)
27 | {
28 | case nameof(DateTime.Year): return "year";
29 | case nameof(DateTime.Month): return "month";
30 | case nameof(DateTime.DayOfYear): return "dayofyear";
31 | case nameof(DateTime.Day): return "day";
32 | case nameof(DateTime.Hour): return "hour";
33 | case nameof(DateTime.Minute): return "minute";
34 | case nameof(DateTime.Second): return "second";
35 | case nameof(DateTime.Millisecond): return "millisecond";
36 | default: return null;
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeDateTimeNowTranslator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using Microsoft.EntityFrameworkCore.Query.Expressions;
4 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
5 |
6 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
7 | {
8 | public class SqlCeDateTimeNowTranslator : IMemberTranslator
9 | {
10 | public virtual Expression Translate(MemberExpression memberExpression)
11 | {
12 | if ((memberExpression.Expression == null)
13 | && (memberExpression.Member.DeclaringType == typeof(DateTime))
14 | && (memberExpression.Member.Name == nameof(DateTime.Now)))
15 | {
16 | return new SqlFunctionExpression("GETDATE", memberExpression.Type);
17 | }
18 |
19 | return null;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeNewGuidTranslator.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
2 | using System;
3 |
4 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
5 | {
6 | public class SqlCeNewGuidTranslator : SingleOverloadStaticMethodCallTranslator
7 | {
8 | public SqlCeNewGuidTranslator()
9 | : base(typeof(Guid), nameof(Guid.NewGuid), "NEWID")
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringIndexOfTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Linq.Expressions;
2 | using System.Reflection;
3 | using Microsoft.EntityFrameworkCore.Query.Expressions;
4 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
5 |
6 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
7 | {
8 | ///
9 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
10 | /// directly from your code. This API may change or be removed in future releases.
11 | ///
12 | public class SqlCeStringIndexOfTranslator : IMethodCallTranslator
13 | {
14 | private static readonly MethodInfo _methodInfo
15 | = typeof(string).GetRuntimeMethod(nameof(string.IndexOf), new[] { typeof(string) });
16 |
17 | ///
18 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
19 | /// directly from your code. This API may change or be removed in future releases.
20 | ///
21 | public virtual Expression Translate(MethodCallExpression methodCallExpression)
22 | {
23 | if (Equals(methodCallExpression.Method, _methodInfo))
24 | {
25 | var patternExpression = methodCallExpression.Arguments[0];
26 |
27 | var charIndexExpression = Expression.Subtract(
28 | new SqlFunctionExpression(
29 | "CHARINDEX",
30 | typeof(int),
31 | new[] { patternExpression, methodCallExpression.Object }),
32 | Expression.Constant(1));
33 |
34 | return patternExpression is ConstantExpression constantExpression
35 | && !string.IsNullOrEmpty((string)constantExpression.Value)
36 | ? (Expression)charIndexExpression
37 | : Expression.Condition(
38 | Expression.Equal(patternExpression, Expression.Constant(string.Empty)),
39 | Expression.Constant(0),
40 | charIndexExpression);
41 | }
42 |
43 | return null;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringIsNullOrWhiteSpaceTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Linq.Expressions;
2 | using System.Reflection;
3 | using Microsoft.EntityFrameworkCore.Query.Expressions;
4 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
5 |
6 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
7 | {
8 | public class SqlCeStringIsNullOrWhiteSpaceTranslator : IMethodCallTranslator
9 | {
10 | private static readonly MethodInfo _methodInfo
11 | = typeof(string).GetRuntimeMethod(nameof(string.IsNullOrWhiteSpace), new[] { typeof(string) });
12 |
13 | public virtual Expression Translate(MethodCallExpression methodCallExpression)
14 | {
15 | if (methodCallExpression.Method.Equals(_methodInfo))
16 | {
17 | var argument = methodCallExpression.Arguments[0];
18 |
19 | return Expression.MakeBinary(
20 | ExpressionType.OrElse,
21 | new IsNullExpression(argument),
22 | Expression.Equal(
23 | new SqlFunctionExpression(
24 | "LTRIM",
25 | typeof(string),
26 | new[]
27 | {
28 | new SqlFunctionExpression(
29 | "RTRIM",
30 | typeof(string),
31 | new [] { argument})
32 | }),
33 | Expression.Constant("", typeof(string))));
34 | }
35 |
36 | return null;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringLengthTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Linq.Expressions;
2 | using Microsoft.EntityFrameworkCore.Query.Expressions;
3 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
4 |
5 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
6 | {
7 | public class SqlCeStringLengthTranslator : IMemberTranslator
8 | {
9 | public virtual Expression Translate(MemberExpression memberExpression)
10 | => (memberExpression.Expression != null)
11 | && (memberExpression.Expression.Type == typeof(string))
12 | && (memberExpression.Member.Name == nameof(string.Length))
13 | ? new SqlFunctionExpression("LEN", memberExpression.Type, new[] { memberExpression.Expression })
14 | : null;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringReplaceTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Linq.Expressions;
3 | using System.Reflection;
4 | using Microsoft.EntityFrameworkCore.Query.Expressions;
5 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
6 |
7 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
8 | {
9 | public class SqlCeStringReplaceTranslator : IMethodCallTranslator
10 | {
11 | private static readonly MethodInfo _methodInfo
12 | = typeof(string).GetRuntimeMethod(nameof(string.Replace), new[] { typeof(string), typeof(string) });
13 |
14 | public virtual Expression Translate(MethodCallExpression methodCallExpression)
15 | => _methodInfo.Equals(methodCallExpression.Method)
16 | ? new SqlFunctionExpression(
17 | "REPLACE",
18 | methodCallExpression.Type,
19 | new[] { methodCallExpression.Object }.Concat(methodCallExpression.Arguments))
20 | : null;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringSubstringTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Linq.Expressions;
2 | using System.Reflection;
3 | using Microsoft.EntityFrameworkCore.Query.Expressions;
4 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
5 |
6 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
7 | {
8 | public class SqlCeStringSubstringTranslator : IMethodCallTranslator
9 | {
10 | private static readonly MethodInfo _methodInfo
11 | = typeof(string).GetRuntimeMethod(nameof(string.Substring), new[] { typeof(int), typeof(int) });
12 |
13 | public virtual Expression Translate(MethodCallExpression methodCallExpression)
14 | => _methodInfo.Equals(methodCallExpression.Method)
15 | ? new SqlFunctionExpression(
16 | "SUBSTRING",
17 | methodCallExpression.Type,
18 | new[] {
19 | methodCallExpression.Object,
20 | // Accomodate for SQL Server Compact assumption of 1-based string indexes
21 | methodCallExpression.Arguments[0].NodeType == ExpressionType.Constant
22 | ? (Expression)Expression.Constant(
23 | (int)((ConstantExpression) methodCallExpression.Arguments[0]).Value + 1)
24 | : Expression.Add(
25 | methodCallExpression.Arguments[0],
26 | Expression.Constant(1)),
27 | methodCallExpression.Arguments[1] })
28 | : null;
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringToLowerTranslator.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
2 |
3 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
4 | {
5 | public class SqlCeStringToLowerTranslator : ParameterlessInstanceMethodCallTranslator
6 | {
7 | public SqlCeStringToLowerTranslator()
8 | : base(typeof(string), nameof(string.ToLower), "LOWER")
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringToUpperTranslator.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
2 |
3 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
4 | {
5 | public class SqlCeStringToUpperTranslator : ParameterlessInstanceMethodCallTranslator
6 | {
7 | public SqlCeStringToUpperTranslator()
8 | : base(typeof(string), nameof(string.ToUpper), "UPPER")
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringTrimEndTranslator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using System.Reflection;
4 | using Microsoft.EntityFrameworkCore.Query.Expressions;
5 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
6 |
7 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
8 | {
9 | public class SqlCeStringTrimEndTranslator : IMethodCallTranslator
10 | {
11 | private static readonly MethodInfo _methodInfo
12 | = typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), new[] { typeof(char[]) });
13 |
14 | public virtual Expression Translate(MethodCallExpression methodCallExpression)
15 | {
16 | if (_methodInfo.Equals(methodCallExpression.Method)
17 | // SqlCe RTRIM does not take arguments
18 | && ((methodCallExpression.Arguments[0] as ConstantExpression)?.Value as Array)?.Length == 0)
19 | {
20 | var sqlArguments = new[] { methodCallExpression.Object };
21 | return new SqlFunctionExpression("RTRIM", methodCallExpression.Type, sqlArguments);
22 | }
23 |
24 | return null;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringTrimStartTranslator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using System.Reflection;
4 | using Microsoft.EntityFrameworkCore.Query.Expressions;
5 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
6 |
7 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
8 | {
9 | public class SqlCeStringTrimStartTranslator : IMethodCallTranslator
10 | {
11 | private static readonly MethodInfo _methodInfo
12 | = typeof(string).GetRuntimeMethod(nameof(string.TrimStart), new[] { typeof(char[]) });
13 |
14 | public virtual Expression Translate(MethodCallExpression methodCallExpression)
15 | {
16 | if (_methodInfo.Equals(methodCallExpression.Method)
17 | // SqlCe LTRIM does not take arguments
18 | && (((methodCallExpression.Arguments[0] as ConstantExpression)?.Value as Array)?.Length == 0))
19 | {
20 | var sqlArguments = new[] { methodCallExpression.Object };
21 | return new SqlFunctionExpression("LTRIM", methodCallExpression.Type, sqlArguments);
22 | }
23 |
24 | return null;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionTranslators/Internal/SqlCeStringTrimTranslator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using System.Reflection;
4 | using Microsoft.EntityFrameworkCore.Query.Expressions;
5 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
6 |
7 | namespace EFCore.SqlCe.Query.ExpressionTranslators.Internal
8 | {
9 | public class SqlCeStringTrimTranslator : IMethodCallTranslator
10 | {
11 | private static readonly MethodInfo _methodInfo
12 | = typeof(string).GetRuntimeMethod(nameof(string.Trim), new Type[] { });
13 |
14 | public virtual Expression Translate(MethodCallExpression methodCallExpression)
15 | {
16 | if (_methodInfo.Equals(methodCallExpression.Method))
17 | {
18 | var sqlArguments = new[] { methodCallExpression.Object };
19 | return new SqlFunctionExpression(
20 | "LTRIM",
21 | methodCallExpression.Type,
22 | new[]
23 | {
24 | new SqlFunctionExpression(
25 | "RTRIM",
26 | methodCallExpression.Type,
27 | sqlArguments),
28 | });
29 | }
30 |
31 | return null;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Provider40/Query/ExpressionVisitors/SqlCeTranslatingExpressionVisitorFactory.cs:
--------------------------------------------------------------------------------
1 | using System.Linq.Expressions;
2 | using JetBrains.Annotations;
3 | using Microsoft.EntityFrameworkCore.Query.Expressions;
4 | using Microsoft.EntityFrameworkCore.Utilities;
5 | using EFCore.SqlCe.Infrastructure.Internal;
6 | using Microsoft.EntityFrameworkCore.Query.ExpressionVisitors;
7 | using Microsoft.EntityFrameworkCore.Query;
8 |
9 | namespace EFCore.SqlCe.Query.ExpressionVisitors
10 | {
11 | ///
12 | /// A factory for creating instances of .
13 | ///
14 | public class SqlCeTranslatingExpressionVisitorFactory : ISqlTranslatingExpressionVisitorFactory
15 | {
16 | private readonly SqlTranslatingExpressionVisitorDependencies _dependencies;
17 | private readonly ISqlCeOptions _sqlCeOptions;
18 |
19 | ///
20 | /// Creates a new instance of .
21 | ///
22 | /// The relational annotation provider.
23 | /// SqlCe options
24 | public SqlCeTranslatingExpressionVisitorFactory(
25 | [NotNull] SqlTranslatingExpressionVisitorDependencies dependencies,
26 | [NotNull] ISqlCeOptions sqlCeOptions)
27 | {
28 | Check.NotNull(dependencies, nameof(dependencies));
29 | Check.NotNull(sqlCeOptions, nameof(sqlCeOptions));
30 |
31 | _dependencies = dependencies;
32 | _sqlCeOptions = sqlCeOptions;
33 | }
34 |
35 | ///
36 | /// Creates a new SqlTranslatingExpressionVisitor.
37 | ///
38 | /// The query model visitor.
39 | /// The target select expression.
40 | /// The top level predicate.
41 | /// true if we are translating a projection.
42 | ///
43 | /// A SqlTranslatingExpressionVisitor.
44 | ///
45 | public virtual SqlTranslatingExpressionVisitor Create(
46 | RelationalQueryModelVisitor queryModelVisitor,
47 | SelectExpression targetSelectExpression = null,
48 | Expression topLevelPredicate = null,
49 | bool inProjection = false)
50 | => new SqlCeTranslatingExpressionVisitor(
51 | _dependencies,
52 | _sqlCeOptions,
53 | Check.NotNull(queryModelVisitor, nameof(queryModelVisitor)),
54 | targetSelectExpression,
55 | topLevelPredicate,
56 | inProjection);
57 | }
58 | }
--------------------------------------------------------------------------------
/src/Provider40/Query/Expressions/Internal/DatePartExpression.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using JetBrains.Annotations;
4 | using Microsoft.EntityFrameworkCore.Utilities;
5 | using EFCore.SqlCe.Query.Sql.Internal;
6 |
7 | namespace EFCore.SqlCe.Query.Expressions.Internal
8 | {
9 | public class DatePartExpression : Expression
10 | {
11 | public DatePartExpression(
12 | [NotNull] string datePart,
13 | [NotNull] Type type,
14 | [NotNull] Expression argument)
15 | {
16 | DatePart = datePart;
17 | Type = type;
18 | Argument = argument;
19 | }
20 |
21 | public override Type Type { get; }
22 | public override ExpressionType NodeType => ExpressionType.Extension;
23 |
24 | public virtual Expression Argument { get; }
25 | public virtual string DatePart { get; }
26 |
27 | protected override Expression Accept(ExpressionVisitor visitor)
28 | {
29 | Check.NotNull(visitor, nameof(visitor));
30 |
31 | var specificVisitor = visitor as ISqlCeExpressionVisitor;
32 |
33 | return specificVisitor != null
34 | ? specificVisitor.VisitDatePartExpression(this)
35 | : base.Accept(visitor);
36 | }
37 |
38 | protected override Expression VisitChildren(ExpressionVisitor visitor) => this;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Provider40/Query/Internal/SqlCeQueryCompilationContext.cs:
--------------------------------------------------------------------------------
1 | using JetBrains.Annotations;
2 | using Microsoft.EntityFrameworkCore.Query;
3 | using Microsoft.EntityFrameworkCore.Query.Internal;
4 |
5 | namespace EFCore.SqlCe.Query.Internal
6 | {
7 | public class SqlCeQueryCompilationContext : RelationalQueryCompilationContext
8 | {
9 | public SqlCeQueryCompilationContext(
10 | [NotNull] QueryCompilationContextDependencies dependencies,
11 | [NotNull] ILinqOperatorProvider linqOperatorProvider,
12 | [NotNull] IQueryMethodProvider queryMethodProvider,
13 | bool trackQueryResults)
14 | : base(
15 | dependencies,
16 | linqOperatorProvider,
17 | queryMethodProvider,
18 | trackQueryResults)
19 | {
20 | }
21 |
22 | public override bool IsLateralJoinSupported => true;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Provider40/Query/Internal/SqlCeQueryCompilationContextFactory.cs:
--------------------------------------------------------------------------------
1 | using JetBrains.Annotations;
2 | using Microsoft.EntityFrameworkCore.Query;
3 | using Microsoft.EntityFrameworkCore.Query.Internal;
4 |
5 | namespace EFCore.SqlCe.Query.Internal
6 | {
7 | public class SqlCeQueryCompilationContextFactory : RelationalQueryCompilationContextFactory
8 | {
9 | public SqlCeQueryCompilationContextFactory(
10 | [NotNull] QueryCompilationContextDependencies dependencies,
11 | [NotNull] RelationalQueryCompilationContextDependencies relationalDependencies)
12 | : base(dependencies, relationalDependencies)
13 | {
14 | }
15 |
16 | public override QueryCompilationContext Create(bool async)
17 | => async
18 | ? new SqlCeQueryCompilationContext(
19 | Dependencies,
20 | new AsyncLinqOperatorProvider(),
21 | new AsyncQueryMethodProvider(),
22 | TrackQueryResults)
23 | : new SqlCeQueryCompilationContext(
24 | Dependencies,
25 | new LinqOperatorProvider(),
26 | new QueryMethodProvider(),
27 | TrackQueryResults);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Provider40/Query/Sql/Internal/ISqlCeExpressionVisitor.cs:
--------------------------------------------------------------------------------
1 | using System.Linq.Expressions;
2 | using EFCore.SqlCe.Query.Expressions.Internal;
3 | using JetBrains.Annotations;
4 |
5 | namespace EFCore.SqlCe.Query.Sql.Internal
6 | {
7 | public interface ISqlCeExpressionVisitor
8 | {
9 | Expression VisitDatePartExpression([NotNull] DatePartExpression datePartExpression);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Provider40/Query/Sql/Internal/SqlCeQuerySqlGeneratorFactory.cs:
--------------------------------------------------------------------------------
1 | using JetBrains.Annotations;
2 | using Microsoft.EntityFrameworkCore.Query.Expressions;
3 | using Microsoft.EntityFrameworkCore.Query.Sql;
4 | using Microsoft.EntityFrameworkCore.Utilities;
5 |
6 | namespace EFCore.SqlCe.Query.Sql.Internal
7 | {
8 | public class SqlCeQuerySqlGeneratorFactory : QuerySqlGeneratorFactoryBase
9 | {
10 | public SqlCeQuerySqlGeneratorFactory([NotNull] QuerySqlGeneratorDependencies dependencies)
11 | : base(dependencies)
12 | {
13 | }
14 |
15 | public override IQuerySqlGenerator CreateDefault(SelectExpression selectExpression)
16 | => new SqlCeQuerySqlGenerator(
17 | Dependencies,
18 | Check.NotNull(selectExpression, nameof(selectExpression)));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Provider40/Scaffolding/Internal/SqlCeCodeGenerator.cs:
--------------------------------------------------------------------------------
1 | using JetBrains.Annotations;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Design;
4 | using Microsoft.EntityFrameworkCore.Scaffolding;
5 |
6 | namespace EFCore.SqlCe.Scaffolding.Internal
7 | {
8 | public class SqlCeCodeGenerator : ProviderCodeGenerator
9 | {
10 | public SqlCeCodeGenerator([NotNull] ProviderCodeGeneratorDependencies dependencies)
11 | : base(dependencies)
12 | {
13 | }
14 |
15 | ///
16 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
17 | /// directly from your code. This API may change or be removed in future releases.
18 | ///
19 | public override MethodCallCodeFragment GenerateUseProvider(
20 | string connectionString,
21 | MethodCallCodeFragment providerOptions)
22 | => new MethodCallCodeFragment(
23 | nameof(SqlCeDbContextOptionsExtensions.UseSqlCe),
24 | providerOptions == null
25 | ? new object[] { connectionString }
26 | : new object[] { connectionString, new NestedClosureCodeFragment("x", providerOptions) });
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Provider40/Scaffolding/Internal/SqlDataReaderExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Common;
2 | using JetBrains.Annotations;
3 |
4 | namespace EFCore.SqlCe.Scaffolding.Internal
5 | {
6 | ///
7 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
8 | /// directly from your code. This API may change or be removed in future releases.
9 | ///
10 | public static class SqlDataReaderExtension
11 | {
12 | ///
13 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
14 | /// directly from your code. This API may change or be removed in future releases.
15 | ///
16 | public static T GetValueOrDefault([NotNull] this DbDataReader reader, [NotNull] string name)
17 | {
18 | var idx = reader.GetOrdinal(name);
19 | return reader.IsDBNull(idx)
20 | ? default(T)
21 | : reader.GetFieldValue(idx);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/ISqlCeDatabaseConnection.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Storage;
2 |
3 | namespace EFCore.SqlCe.Storage.Internal
4 | {
5 | public interface ISqlCeDatabaseConnection : IRelationalConnection
6 | {
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeByteTypeMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using Microsoft.EntityFrameworkCore.Storage;
3 | using JetBrains.Annotations;
4 |
5 | namespace EFCore.SqlCe.Storage.Internal
6 | {
7 | ///
8 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
9 | /// directly from your code. This API may change or be removed in future releases.
10 | ///
11 | public class SqlCeByteTypeMapping : ByteTypeMapping
12 | {
13 | ///
14 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
15 | /// directly from your code. This API may change or be removed in future releases.
16 | ///
17 | public SqlCeByteTypeMapping(
18 | [NotNull] string storeType,
19 | DbType? dbType = null)
20 | : base(storeType, dbType)
21 | {
22 | }
23 |
24 | ///
25 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
26 | /// directly from your code. This API may change or be removed in future releases.
27 | ///
28 | protected SqlCeByteTypeMapping(RelationalTypeMappingParameters parameters)
29 | : base(parameters)
30 | {
31 | }
32 |
33 | ///
34 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
35 | /// directly from your code. This API may change or be removed in future releases.
36 | ///
37 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
38 | => new SqlCeByteTypeMapping(parameters);
39 |
40 | ///
41 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
42 | /// directly from your code. This API may change or be removed in future releases.
43 | ///
44 | protected override string GenerateNonNullSqlLiteral(object value)
45 | => $"CAST({base.GenerateNonNullSqlLiteral(value)} AS {StoreType})";
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeConnectionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Data.SqlServerCe;
2 | using System.IO;
3 | using JetBrains.Annotations;
4 | using Microsoft.EntityFrameworkCore;
5 | using Microsoft.EntityFrameworkCore.Utilities;
6 |
7 | namespace EFCore.SqlCe.Storage.Internal
8 | {
9 | public static class SqlCeConnectionExtensions
10 | {
11 | public static void CreateEmptyDatabase([NotNull] this SqlCeConnection connection)
12 | {
13 | Check.NotNull(connection, nameof(connection));
14 |
15 | using (var engine = new SqlCeEngine(connection.ConnectionString))
16 | {
17 | engine.CreateDatabase();
18 | }
19 | }
20 |
21 | public static bool Exists([NotNull] this SqlCeConnection connection)
22 | {
23 | Check.NotNull(connection, nameof(connection));
24 | return File.Exists(SqlCeHelper.PathFromConnectionString(connection.ConnectionString));
25 | }
26 |
27 | public static void Drop([NotNull] this SqlCeConnection connection, bool throwOnOpen = true)
28 | {
29 | Check.NotNull(connection, nameof(connection));
30 |
31 | if (throwOnOpen)
32 | {
33 | connection.Open();
34 | }
35 | connection.Close();
36 | var path = SqlCeHelper.PathFromConnectionString(connection.ConnectionString);
37 | if (File.Exists(path))
38 | {
39 | File.Delete(path);
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeDatabaseConnection.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Common;
2 | using System.Data.SqlServerCe;
3 | using JetBrains.Annotations;
4 | using Microsoft.EntityFrameworkCore.Storage;
5 |
6 | namespace EFCore.SqlCe.Storage.Internal
7 | {
8 | public class SqlCeDatabaseConnection : RelationalConnection, ISqlCeDatabaseConnection
9 | {
10 | public SqlCeDatabaseConnection([NotNull] RelationalConnectionDependencies dependencies)
11 | : base(dependencies)
12 | {
13 | }
14 |
15 | protected override DbConnection CreateDbConnection() => new SqlCeConnection(ConnectionString);
16 |
17 | public override bool IsMultipleActiveResultSetsEnabled => true;
18 |
19 | protected override bool SupportsAmbientTransactions => true;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeDatabaseCreator.cs:
--------------------------------------------------------------------------------
1 | using System.Data.SqlServerCe;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using JetBrains.Annotations;
5 | using Microsoft.EntityFrameworkCore.Storage;
6 | using Microsoft.EntityFrameworkCore.Utilities;
7 |
8 | namespace EFCore.SqlCe.Storage.Internal
9 | {
10 | public class SqlCeDatabaseCreator : RelationalDatabaseCreator
11 | {
12 | private readonly ISqlCeDatabaseConnection _connection;
13 | private readonly IRawSqlCommandBuilder _rawSqlCommandBuilder;
14 |
15 | public SqlCeDatabaseCreator(
16 | [NotNull] RelationalDatabaseCreatorDependencies dependencies,
17 | [NotNull] ISqlCeDatabaseConnection connection,
18 | [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder)
19 | : base(dependencies)
20 | {
21 | _connection = connection;
22 | _rawSqlCommandBuilder = rawSqlCommandBuilder;
23 | }
24 |
25 | public override void Create()
26 | {
27 | Check.NotNull(_connection, nameof(_connection));
28 | var connection = _connection.DbConnection as SqlCeConnection;
29 | connection?.CreateEmptyDatabase();
30 | }
31 |
32 | public override bool Exists()
33 | {
34 | var connection = _connection.DbConnection as SqlCeConnection;
35 | return (connection != null) && connection.Exists();
36 | }
37 |
38 | protected override bool HasTables()
39 | => (int)CreateHasTablesCommand().ExecuteScalar(_connection) != 0;
40 |
41 | protected override async Task HasTablesAsync(CancellationToken cancellationToken = default(CancellationToken))
42 | => (int)await CreateHasTablesCommand().ExecuteScalarAsync(_connection, cancellationToken: cancellationToken) != 0;
43 |
44 | private IRelationalCommand CreateHasTablesCommand()
45 | => _rawSqlCommandBuilder
46 | .Build("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE <> N'SYSTEM TABLE';");
47 |
48 | public override void Delete()
49 | {
50 | var connection = _connection.DbConnection as SqlCeConnection;
51 | connection?.Drop();
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeDateTimeTypeMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using JetBrains.Annotations;
3 | using Microsoft.EntityFrameworkCore.Storage;
4 |
5 | namespace EFCore.SqlCe.Storage.Internal
6 | {
7 | ///
8 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
9 | /// directly from your code. This API may change or be removed in future releases.
10 | ///
11 | public class SqlCeDateTimeTypeMapping : DateTimeTypeMapping
12 | {
13 | private const string DateTimeFormatConst = "{0:yyyy-MM-ddTHH:mm:ss.fff}";
14 |
15 | ///
16 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
17 | /// directly from your code. This API may change or be removed in future releases.
18 | ///
19 | public SqlCeDateTimeTypeMapping(
20 | [NotNull] string storeType,
21 | DbType? dbType = null)
22 | : base(storeType, dbType)
23 | {
24 | }
25 |
26 | ///
27 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
28 | /// directly from your code. This API may change or be removed in future releases.
29 | ///
30 | protected SqlCeDateTimeTypeMapping(RelationalTypeMappingParameters parameters)
31 | : base(parameters)
32 | {
33 | }
34 |
35 | ///
36 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
37 | /// directly from your code. This API may change or be removed in future releases.
38 | ///
39 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
40 | => new SqlCeDateTimeTypeMapping(parameters);
41 |
42 | ///
43 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
44 | /// directly from your code. This API may change or be removed in future releases.
45 | ///
46 | protected override string SqlLiteralFormatString
47 | => "'" + DateTimeFormatConst + "'";
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeDecimalTypeMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using System.Data.Common;
3 | using JetBrains.Annotations;
4 | using Microsoft.EntityFrameworkCore.Storage;
5 |
6 | namespace EFCore.SqlCe.Storage.Internal
7 | {
8 | ///
9 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
10 | /// directly from your code. This API may change or be removed in future releases.
11 | ///
12 | public class SqlCeDecimalTypeMapping : DecimalTypeMapping
13 | {
14 | ///
15 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
16 | /// directly from your code. This API may change or be removed in future releases.
17 | ///
18 | public SqlCeDecimalTypeMapping(
19 | [NotNull] string storeType,
20 | DbType? dbType = null,
21 | int? precision = null,
22 | int? scale = null)
23 | : base(
24 | new RelationalTypeMappingParameters(
25 | new CoreTypeMappingParameters(typeof(decimal)),
26 | storeType,
27 | StoreTypePostfix.PrecisionAndScale,
28 | dbType,
29 | precision: precision,
30 | scale: scale))
31 | {
32 | }
33 |
34 | ///
35 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
36 | /// directly from your code. This API may change or be removed in future releases.
37 | ///
38 | protected SqlCeDecimalTypeMapping(RelationalTypeMappingParameters parameters)
39 | : base(parameters)
40 | {
41 | }
42 |
43 | ///
44 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
45 | /// directly from your code. This API may change or be removed in future releases.
46 | ///
47 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
48 | => new SqlCeDecimalTypeMapping(parameters);
49 |
50 | ///
51 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
52 | /// directly from your code. This API may change or be removed in future releases.
53 | ///
54 | protected override void ConfigureParameter(DbParameter parameter)
55 | {
56 | base.ConfigureParameter(parameter);
57 |
58 | if (Size.HasValue
59 | && Size.Value != -1)
60 | {
61 | parameter.Size = Size.Value;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeDoubleTypeMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using System.Data.Common;
3 | using JetBrains.Annotations;
4 | using Microsoft.EntityFrameworkCore.Storage;
5 |
6 | namespace EFCore.SqlCe.Storage.Internal
7 | {
8 | ///
9 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
10 | /// directly from your code. This API may change or be removed in future releases.
11 | ///
12 | public class SqlCeDoubleTypeMapping : DoubleTypeMapping
13 | {
14 | ///
15 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
16 | /// directly from your code. This API may change or be removed in future releases.
17 | ///
18 | public SqlCeDoubleTypeMapping(
19 | [NotNull] string storeType,
20 | DbType? dbType = null)
21 | : base(storeType, dbType)
22 | {
23 | }
24 |
25 | ///
26 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
27 | /// directly from your code. This API may change or be removed in future releases.
28 | ///
29 | protected SqlCeDoubleTypeMapping(RelationalTypeMappingParameters parameters)
30 | : base(parameters)
31 | {
32 | }
33 |
34 | ///
35 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
36 | /// directly from your code. This API may change or be removed in future releases.
37 | ///
38 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
39 | => new SqlCeDoubleTypeMapping(parameters);
40 |
41 | ///
42 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
43 | /// directly from your code. This API may change or be removed in future releases.
44 | ///
45 | protected override void ConfigureParameter(DbParameter parameter)
46 | {
47 | base.ConfigureParameter(parameter);
48 |
49 | if (Size.HasValue
50 | && Size.Value != -1)
51 | {
52 | parameter.Size = Size.Value;
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeLongTypeMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using Microsoft.EntityFrameworkCore.Storage;
3 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
4 | using JetBrains.Annotations;
5 |
6 | namespace EFCore.SqlCe.Storage.Internal
7 | {
8 | ///
9 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
10 | /// directly from your code. This API may change or be removed in future releases.
11 | ///
12 | public class SqlCeLongTypeMapping : LongTypeMapping
13 | {
14 | ///
15 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
16 | /// directly from your code. This API may change or be removed in future releases.
17 | ///
18 | public SqlCeLongTypeMapping(
19 | [NotNull] string storeType,
20 | DbType? dbType = null)
21 | : base(storeType, dbType)
22 | {
23 | }
24 |
25 | ///
26 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
27 | /// directly from your code. This API may change or be removed in future releases.
28 | ///
29 | protected SqlCeLongTypeMapping(RelationalTypeMappingParameters parameters)
30 | : base(parameters)
31 | {
32 | }
33 |
34 | ///
35 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
36 | /// directly from your code. This API may change or be removed in future releases.
37 | ///
38 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
39 | => new SqlCeLongTypeMapping(parameters);
40 |
41 | ///
42 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
43 | /// directly from your code. This API may change or be removed in future releases.
44 | ///
45 | protected override string GenerateNonNullSqlLiteral(object value)
46 | => $"CAST({base.GenerateNonNullSqlLiteral(value)} AS {StoreType})";
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeShortTypeMapping.cs:
--------------------------------------------------------------------------------
1 | using System.Data;
2 | using Microsoft.EntityFrameworkCore.Storage;
3 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
4 | using JetBrains.Annotations;
5 |
6 | namespace EFCore.SqlCe.Storage.Internal
7 | {
8 | ///
9 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
10 | /// directly from your code. This API may change or be removed in future releases.
11 | ///
12 | public class SqlCeShortTypeMapping : ShortTypeMapping
13 | {
14 | ///
15 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
16 | /// directly from your code. This API may change or be removed in future releases.
17 | ///
18 | public SqlCeShortTypeMapping(
19 | [NotNull] string storeType,
20 | DbType? dbType = null)
21 | : base(storeType, dbType)
22 | {
23 | }
24 |
25 | ///
26 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
27 | /// directly from your code. This API may change or be removed in future releases.
28 | ///
29 | protected SqlCeShortTypeMapping(RelationalTypeMappingParameters parameters)
30 | : base(parameters)
31 | {
32 | }
33 |
34 | ///
35 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
36 | /// directly from your code. This API may change or be removed in future releases.
37 | ///
38 | protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
39 | => new SqlCeShortTypeMapping(parameters);
40 |
41 | ///
42 | /// This API supports the Entity Framework Core infrastructure and is not intended to be used
43 | /// directly from your code. This API may change or be removed in future releases.
44 | ///
45 | protected override string GenerateNonNullSqlLiteral(object value)
46 | => $"CAST({base.GenerateNonNullSqlLiteral(value)} AS {StoreType})";
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Provider40/Storage/Internal/SqlCeSqlGenerationHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using JetBrains.Annotations;
4 | using Microsoft.EntityFrameworkCore.Storage;
5 | using Microsoft.EntityFrameworkCore.Utilities;
6 |
7 | namespace EFCore.SqlCe.Storage.Internal
8 | {
9 | public class SqlCeSqlGenerationHelper : RelationalSqlGenerationHelper
10 | {
11 | public SqlCeSqlGenerationHelper([NotNull] RelationalSqlGenerationHelperDependencies dependencies)
12 | : base(dependencies)
13 | {
14 | }
15 |
16 | public override string BatchTerminator => "GO" + Environment.NewLine + Environment.NewLine;
17 |
18 | public override string StatementTerminator => Environment.NewLine;
19 |
20 | public override string EscapeIdentifier(string identifier)
21 | => Check.NotEmpty(identifier, nameof(identifier)).Replace("]", "]]");
22 |
23 | public override string DelimitIdentifier(string identifier)
24 | => $"[{EscapeIdentifier(Check.NotEmpty(identifier, nameof(identifier)))}]";
25 |
26 | public override void DelimitIdentifier(StringBuilder builder, string identifier)
27 | {
28 | Check.NotEmpty(identifier, nameof(identifier));
29 |
30 | builder.Append('[');
31 | EscapeIdentifier(builder, identifier);
32 | builder.Append(']');
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Provider40/Update/Internal/ISqlCeUpdateSqlGenerator.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Update;
2 |
3 | namespace EFCore.SqlCe.Update.Internal
4 | {
5 | public interface ISqlCeUpdateSqlGenerator : IUpdateSqlGenerator
6 | {
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/Provider40/Update/Internal/SqlCeModificationCommandBatchFactory.cs:
--------------------------------------------------------------------------------
1 | using JetBrains.Annotations;
2 | using Microsoft.EntityFrameworkCore.Infrastructure;
3 | using Microsoft.EntityFrameworkCore.Storage;
4 | using Microsoft.EntityFrameworkCore.Update;
5 | using Microsoft.EntityFrameworkCore.Utilities;
6 |
7 | namespace EFCore.SqlCe.Update.Internal
8 | {
9 | public class SqlCeModificationCommandBatchFactory : IModificationCommandBatchFactory
10 | {
11 | private readonly IRelationalCommandBuilderFactory _commandBuilderFactory;
12 | private readonly ISqlGenerationHelper _sqlGenerationHelper;
13 | private readonly ISqlCeUpdateSqlGenerator _updateSqlGenerator;
14 | private readonly IRelationalValueBufferFactoryFactory _valueBufferFactoryFactory;
15 |
16 | public SqlCeModificationCommandBatchFactory(
17 | [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
18 | [NotNull] ISqlGenerationHelper sqlGenerationHelper,
19 | [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
20 | [NotNull] ISqlCeUpdateSqlGenerator updateSqlGenerator,
21 | [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
22 | [NotNull] IDbContextOptions options)
23 | {
24 | Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
25 | Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
26 | Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
27 | Check.NotNull(options, nameof(options));
28 | Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));
29 |
30 | _commandBuilderFactory = commandBuilderFactory;
31 | _sqlGenerationHelper = sqlGenerationHelper;
32 | _updateSqlGenerator = updateSqlGenerator;
33 | _valueBufferFactoryFactory = valueBufferFactoryFactory;
34 | }
35 |
36 | public virtual ModificationCommandBatch Create()
37 | {
38 | return new SqlCeModificationCommandBatch(
39 | _commandBuilderFactory,
40 | _sqlGenerationHelper,
41 | _updateSqlGenerator,
42 | _valueBufferFactoryFactory);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Provider40/Update/Internal/SqlCeUpdateSqlGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using JetBrains.Annotations;
4 | using Microsoft.EntityFrameworkCore.Update;
5 | using Microsoft.EntityFrameworkCore.Utilities;
6 |
7 | namespace EFCore.SqlCe.Update.Internal
8 | {
9 | public class SqlCeUpdateSqlGenerator : UpdateSqlGenerator, ISqlCeUpdateSqlGenerator
10 | {
11 | public SqlCeUpdateSqlGenerator(
12 | [NotNull] UpdateSqlGeneratorDependencies dependencies)
13 | : base(dependencies)
14 | {
15 | }
16 |
17 | protected override void AppendIdentityWhereCondition(StringBuilder builder, ColumnModification columnModification)
18 | {
19 | Check.NotNull(builder, nameof(builder));
20 | Check.NotNull(columnModification, nameof(columnModification));
21 |
22 | var castAs = columnModification.Property.ClrType == typeof(int)
23 | ? "int"
24 | : "bigint";
25 |
26 | builder
27 | .Append(SqlGenerationHelper.DelimitIdentifier(columnModification.ColumnName))
28 | .Append(" = ")
29 | .Append("CAST (@@IDENTITY AS ")
30 | .Append(castAs)
31 | .Append(")");
32 | }
33 |
34 | protected override void AppendRowsAffectedWhereCondition(StringBuilder builder, int expectedRowsAffected)
35 | {
36 | Check.NotNull(builder, nameof(builder));
37 |
38 | builder
39 | .Append("1 = 1");
40 | }
41 |
42 | public override string GenerateNextSequenceValueOperation(string name, string schema)
43 | {
44 | throw new NotSupportedException();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Provider40/Utilities/Check.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Diagnostics;
6 | using JetBrains.Annotations;
7 |
8 | // ReSharper disable once CheckNamespace
9 |
10 | namespace Microsoft.EntityFrameworkCore.Utilities
11 | {
12 | [DebuggerStepThrough]
13 | internal static class Check
14 | {
15 | [ContractAnnotation("value:null => halt")]
16 | public static T NotNull([NoEnumeration] T value, [InvokerParameterName] [NotNull] string parameterName)
17 | {
18 | #pragma warning disable IDE0041 // Use 'is null' check
19 | if (ReferenceEquals(value, null))
20 | #pragma warning restore IDE0041 // Use 'is null' check
21 | {
22 | NotEmpty(parameterName, nameof(parameterName));
23 |
24 | throw new ArgumentNullException(parameterName);
25 | }
26 |
27 | return value;
28 | }
29 |
30 | [ContractAnnotation("value:null => halt")]
31 | public static string NotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)
32 | {
33 | Exception e = null;
34 | if (value is null)
35 | {
36 | e = new ArgumentNullException(parameterName);
37 | }
38 | else if (value.Trim().Length == 0)
39 | {
40 | e = new ArgumentException($"The string argument '{parameterName}' cannot be empty.");
41 | }
42 |
43 | if (e != null)
44 | {
45 | NotEmpty(parameterName, nameof(parameterName));
46 |
47 | throw e;
48 | }
49 |
50 | return value;
51 | }
52 |
53 | public static string NullButNotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)
54 | {
55 | if (!(value is null)
56 | && (value.Length == 0))
57 | {
58 | NotEmpty(parameterName, nameof(parameterName));
59 |
60 | throw new ArgumentException($"The string argument '{parameterName}' cannot be empty.");
61 | }
62 |
63 | return value;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/Provider40/Utilities/SqlCeHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Data.SqlServerCe;
2 | using JetBrains.Annotations;
3 | using Microsoft.EntityFrameworkCore.Utilities;
4 |
5 | // ReSharper disable once CheckNamespace
6 |
7 | namespace EFCore.SqlCe
8 | {
9 | public static class SqlCeHelper
10 | {
11 | public static string PathFromConnectionString([NotNull] string connectionString)
12 | {
13 | Check.NotNull(connectionString, nameof(connectionString));
14 | #if SQLCE35
15 | var conn = new SqlCeConnection(GetFullConnectionString(connectionString));
16 | return conn.Database;
17 | #else
18 | var sb = new SqlCeConnectionStringBuilder(GetFullConnectionString(connectionString));
19 | return sb.DataSource;
20 | #endif
21 | }
22 |
23 | private static string GetFullConnectionString(string connectionString)
24 | {
25 | using (var repl = new SqlCeReplication())
26 | {
27 | repl.SubscriberConnectionString = connectionString;
28 | return repl.SubscriberConnectionString;
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Provider40/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/BasicEndToEndScenarioForIdentity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlServerCe;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using Xunit;
6 |
7 | namespace Microsoft.EntityFrameworkCore
8 | {
9 | public class BasicEndToEndScenarioForIdentity
10 | {
11 | [Fact]
12 | public void Can_run_end_to_end_scenario()
13 | {
14 | using (var db = new BloggingContext())
15 | {
16 | db.ConfigureLogging(x => Debug.WriteLine(x));
17 | db.Database.EnsureDeleted();
18 | db.Database.EnsureCreated();
19 | db.Blogs.Add(new Blog { Url = "http://erikej.blogspot.com" });
20 | db.SaveChanges();
21 |
22 | foreach (var entity in db.Model.GetEntityTypes())
23 | {
24 | Console.WriteLine($" {entity.ClrType.Name} => {entity.SqlCe().TableName}");
25 | }
26 |
27 |
28 | var blogs = db.Blogs.ToList();
29 |
30 | Assert.Equal(blogs.Count, 1);
31 | Assert.Equal(blogs[0].Url, "http://erikej.blogspot.com");
32 | }
33 | }
34 |
35 | public class BloggingContext : DbContext
36 | {
37 | public DbSet Blogs { get; set; }
38 | #if SQLCE35
39 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
40 | {
41 | optionsBuilder.UseSqlCe(@"Data Source=BloggingIdentity.sdf");
42 | }
43 | #else
44 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlCe(
45 | new SqlCeConnectionStringBuilder
46 | {
47 | DataSource = "BloggingIdentity.sdf"
48 | }
49 | .ConnectionString);
50 | #endif
51 | }
52 |
53 | public class Blog
54 | {
55 | public int Id { get; set; }
56 | public string Url { get; set; }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/CompositeKeyEndToEndSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore
4 | {
5 | public class CompositeKeyEndToEndSqlCeTest : CompositeKeyEndToEndTestBase
6 | {
7 | public CompositeKeyEndToEndSqlCeTest(CompositeKeyEndToEndSqlCeFixture fixture)
8 | : base(fixture)
9 | {
10 | }
11 |
12 | public class CompositeKeyEndToEndSqlCeFixture : CompositeKeyEndToEndFixtureBase
13 | {
14 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/ConcurrencyDetectorSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Query;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class ConcurrencyDetectorSqlCeTest : ConcurrencyDetectorRelationalTestBase>
7 | {
8 | public ConcurrencyDetectorSqlCeTest(NorthwindQuerySqlCeFixture fixture)
9 | : base(fixture)
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/DataBindingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.EntityFrameworkCore
2 | {
3 | public class DatabindingSqlCeTest : DatabindingTestBase
4 | {
5 | public DatabindingSqlCeTest(F1SqlCeFixture fixture)
6 | : base(fixture)
7 | {
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/EFCore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/test/EntityFramework.SqlServerCompact.FunctionalTests/EFCore.png
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/F1SqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using EFCore.SqlCe.Metadata.Conventions.Internal;
2 | using Microsoft.EntityFrameworkCore.TestModels.ConcurrencyModel;
3 | using Microsoft.EntityFrameworkCore.TestUtilities;
4 |
5 | namespace Microsoft.EntityFrameworkCore
6 | {
7 | public class F1SqlCeFixture : F1RelationalFixture
8 | {
9 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
10 |
11 | public override ModelBuilder CreateModelBuilder()
12 | => new ModelBuilder(SqlCeConventionSetBuilder.Build());
13 |
14 | protected override void BuildModelExternal(ModelBuilder modelBuilder)
15 | {
16 | base.BuildModelExternal(modelBuilder);
17 |
18 | modelBuilder.Entity().Property("Version").IsRowVersion();
19 | modelBuilder.Entity().Property("Version").IsRowVersion();
20 |
21 | modelBuilder.Entity().Property("Version")
22 | .ValueGeneratedOnAddOrUpdate()
23 | .IsConcurrencyToken();
24 |
25 | modelBuilder.Entity()
26 | .OwnsOne(s => s.Details)
27 | .Property(d => d.Space).HasColumnType("decimal(18,2)");
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/FieldMappingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 | using Microsoft.EntityFrameworkCore.Storage;
3 | using Microsoft.EntityFrameworkCore.TestUtilities;
4 |
5 | namespace Microsoft.EntityFrameworkCore
6 | {
7 | public class FieldMappingSqlCeTest : FieldMappingTestBase
8 | {
9 | public FieldMappingSqlCeTest(FieldMappingSqlCeFixture fixture)
10 | : base(fixture)
11 | {
12 | }
13 |
14 | protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
15 | => facade.UseTransaction(transaction.GetDbTransaction());
16 |
17 | public class FieldMappingSqlCeFixture : FieldMappingFixtureBase
18 | {
19 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/GraphUpdateWithIdentitySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 | using Microsoft.EntityFrameworkCore.Storage;
3 | using Microsoft.EntityFrameworkCore.TestUtilities;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.Extensions.Logging;
6 | using Xunit;
7 |
8 | namespace Microsoft.EntityFrameworkCore
9 | {
10 | //public abstract class GraphUpdatesSqlCeTestBase : GraphUpdatesTestBase
11 | // where TFixture : GraphUpdatesSqlCeTestBase.GraphUpdatesSqlCeFixtureBase, new()
12 | //{
13 | // protected GraphUpdatesSqlCeTestBase(TFixture fixture)
14 | // : base(fixture)
15 | // {
16 | // }
17 |
18 | // protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
19 | // => facade.UseTransaction(transaction.GetDbTransaction());
20 |
21 | // public abstract class GraphUpdatesSqlCeFixtureBase : GraphUpdatesFixtureBase
22 | // {
23 | // public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService();
24 | // protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
25 | // }
26 | //}
27 |
28 | //public class GraphUpdatesWithIdentitySqlCeTest : GraphUpdatesSqlCeTestBase
29 | //{
30 | // public GraphUpdatesWithIdentitySqlCeTest(GraphUpdatesWithIdentitySqlCeFixture fixture)
31 | // : base(fixture)
32 | // {
33 | // }
34 |
35 | // [Fact(Skip = "SQL CE limitation: Unique keys not enforced for nullable FKs")]
36 | // public override DbUpdateException Optional_One_to_one_with_AK_relationships_are_one_to_one()
37 | // {
38 | // return base.Optional_One_to_one_with_AK_relationships_are_one_to_one();
39 | // }
40 |
41 | // [Fact(Skip = "SQL CE limitation: Unique keys not enforced for nullable FKs")]
42 | // public override DbUpdateException Optional_One_to_one_relationships_are_one_to_one()
43 | // {
44 | // return base.Optional_One_to_one_relationships_are_one_to_one();
45 | // }
46 |
47 | // public class GraphUpdatesWithIdentitySqlCeFixture : GraphUpdatesSqlCeFixtureBase
48 | // {
49 | // protected override string StoreName { get; } = "GraphIdentityUpdatesTest";
50 | // }
51 | //}
52 | }
53 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Issue305Test.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xunit;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class Issue305Test
7 | {
8 | [Fact]
9 | public void Issue305_Test()
10 | {
11 | using (var db = new TiffFilesContext())
12 | {
13 | db.Database.EnsureDeleted();
14 |
15 | db.Database.Migrate();
16 | }
17 | }
18 |
19 | public class TiffFilesContext : DbContext
20 | {
21 | public DbSet Files { get; set; }
22 |
23 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
24 | {
25 | optionsBuilder.UseSqlCe(@"Data Source=Issue305Database.sdf");
26 | }
27 |
28 | protected override void OnModelCreating(ModelBuilder modelBuilder)
29 | {
30 | modelBuilder.Entity().Property(f => f.Path).IsRequired();
31 | }
32 | }
33 |
34 | public class FileInfo
35 | {
36 | public int FileInfoId { get; set; }
37 | public string Path { get; set; }
38 | public string BlindedName { get; set; }
39 | public bool ContainsSynapse { get; set; }
40 | public int Quality { get; set; }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Issue398Test.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Xunit;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class Issue398Test
7 | {
8 | [Fact]
9 | public void Issue398_Test()
10 | {
11 | using (var db = new BloggingContext())
12 | {
13 | db.Database.EnsureDeleted();
14 | db.Database.Migrate();
15 | }
16 | }
17 |
18 | public class BloggingContext : DbContext
19 | {
20 | public DbSet Blogs { get; set; }
21 | public DbSet Posts { get; set; }
22 |
23 | protected override void OnConfiguring(DbContextOptionsBuilder dbContextOptionsBuilder)
24 | {
25 | dbContextOptionsBuilder.UseSqlCe(@"Data Source=Issue398.sdf");
26 | }
27 |
28 | protected override void OnModelCreating(ModelBuilder modelBuilder)
29 | {
30 | modelBuilder.Entity()
31 | .HasMany(b => b.Posts)
32 | .WithOne(p => p.Blog)
33 | .HasForeignKey(p => p.BlogId);
34 | modelBuilder.Entity()
35 | .HasIndex(p => p.BlogId)
36 | .HasName("NewIndex");
37 | }
38 | }
39 |
40 | public class Blog
41 | {
42 | public int BlogId { get; set; }
43 | public string Url { get; set; }
44 |
45 | public List Posts { get; set; }
46 | }
47 |
48 | public class Post
49 | {
50 | public int PostId { get; set; }
51 | public string Title { get; set; }
52 | public string Content { get; set; }
53 |
54 | public int BlogId { get; set; }
55 | public Blog Blog { get; set; }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Issue541Test.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Xunit;
4 |
5 | namespace Microsoft.EntityFrameworkCore
6 | {
7 | public class Issue541Test
8 | {
9 | [Fact]
10 | public void Issue541_Test()
11 | {
12 | using (var db = new Issue541Context())
13 | {
14 | db.Database.EnsureDeleted();
15 | db.Database.EnsureCreated();
16 |
17 | db.ServerData.AddRange(new List
18 | {
19 | new ServerData { ServerId = 6, Type = 1, Value = 5, Date = DateTime.UtcNow },
20 | new ServerData { ServerId = 6, Type = 2, Value = 6.56m, Date = DateTime.UtcNow },
21 | });
22 |
23 | //Fix issue by supplying a date
24 |
25 | db.SaveChanges();
26 | }
27 | }
28 |
29 | public class Issue541Context : DbContext
30 | {
31 | public DbSet ServerData { get; set; }
32 |
33 | protected override void OnConfiguring(DbContextOptionsBuilder dbContextOptionsBuilder)
34 | {
35 | dbContextOptionsBuilder.UseSqlCe(@"Data Source=Issue541.sdf");
36 | }
37 |
38 | protected override void OnModelCreating(ModelBuilder modelBuilder)
39 | {
40 | modelBuilder.Entity(entity =>
41 | {
42 | entity.HasKey(e => new { e.ServerId, e.Type, e.Date });
43 |
44 | entity.Property(e => e.Date)
45 | .HasColumnType("datetime")
46 | .HasDefaultValueSql("getdate()");
47 |
48 | entity.Property(e => e.Value).HasColumnType("decimal(15, 1)");
49 | });
50 | }
51 | }
52 |
53 | public partial class ServerData
54 | {
55 | public long ServerId { get; set; }
56 | public DateTime Date { get; set; }
57 | public short Type { get; set; }
58 | public decimal Value { get; set; }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/LoggingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EFCore.SqlCe.Infrastructure.Internal;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Xunit;
5 |
6 | // ReSharper disable InconsistentNaming
7 | namespace Microsoft.EntityFrameworkCore
8 | {
9 | public class LoggingSqlCeTest : LoggingRelationalTestBase
10 | {
11 | [Fact]
12 | public void Logs_context_initialization_()
13 | {
14 | Assert.Equal(
15 | ExpectedMessage("ClientEvalForUnsupportedSqlConstructs "),
16 | ActualMessage(CreateOptionsBuilder(b => ((SqlCeDbContextOptionsBuilder)b).UseClientEvalForUnsupportedSqlConstructs(true))));
17 | }
18 |
19 | protected override DbContextOptionsBuilder CreateOptionsBuilder(
20 | Action> relationalAction)
21 | => new DbContextOptionsBuilder().UseSqlCe("Data Source=LoggingSqlServerTest.db", relationalAction);
22 |
23 | protected override string ProviderName => "EntityFrameworkCore.SqlServerCompact40";
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/20160215092248_Migration01.Designer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using ConsoleApplication3;
7 | using Microsoft.EntityFrameworkCore.Specification.Tests;
8 |
9 | namespace ConsoleApplication3.Migrations
10 | {
11 | [DbContext(typeof(Issue305Test.TiffFilesContext))]
12 | [Migration("20160215092248_Migration01")]
13 | partial class Migration01
14 | {
15 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
16 | {
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "1.0.0");
19 |
20 | modelBuilder.Entity("ConsoleApplication3.FileInfo", b =>
21 | {
22 | b.ToTable("FileInfo");
23 |
24 | b.Property("FileInfoId")
25 | .ValueGeneratedOnAdd();
26 |
27 | b.Property("BlindedName");
28 |
29 | b.Property("ContainsSynapse");
30 |
31 | b.Property("Path")
32 | .IsRequired();
33 |
34 | b.HasKey("FileInfoId");
35 | });
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/20160215092248_Migration01.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore.Migrations;
4 |
5 | namespace ConsoleApplication3.Migrations
6 | {
7 | public partial class Migration01 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "FileInfo",
13 | columns: table => new
14 | {
15 | FileInfoId = table.Column(nullable: false)
16 | .Annotation("SqlCe:ValueGeneration", "True"),
17 | BlindedName = table.Column(nullable: true),
18 | ContainsSynapse = table.Column(nullable: false),
19 | Path = table.Column(nullable: false)
20 | },
21 | constraints: table =>
22 | {
23 | table.PrimaryKey("PK_FileInfo", x => x.FileInfoId);
24 | });
25 | }
26 |
27 | protected override void Down(MigrationBuilder migrationBuilder)
28 | {
29 | migrationBuilder.DropTable(
30 | name: "FileInfo");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/20160215092329_Migration02.Designer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using ConsoleApplication3;
7 | using Microsoft.EntityFrameworkCore.Specification.Tests;
8 |
9 | namespace ConsoleApplication3.Migrations
10 | {
11 | [DbContext(typeof(Issue305Test.TiffFilesContext))]
12 | [Migration("20160215092329_Migration02")]
13 | partial class Migration02
14 | {
15 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
16 | {
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "1.0.0");
19 |
20 | modelBuilder.Entity("ConsoleApplication3.FileInfo", b =>
21 | {
22 | b.ToTable("FileInfo");
23 |
24 | b.Property("FileInfoId")
25 | .ValueGeneratedOnAdd();
26 |
27 | b.Property("BlindedName");
28 |
29 | b.Property("ContainsSynapse");
30 |
31 | b.Property("Path")
32 | .IsRequired();
33 |
34 | b.Property("Quality");
35 |
36 | b.HasKey("FileInfoId");
37 | });
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/20160215092329_Migration02.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore.Migrations;
4 |
5 | namespace ConsoleApplication3.Migrations
6 | {
7 | public partial class Migration02 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.AddColumn(
12 | name: "Quality",
13 | table: "FileInfo",
14 | nullable: false,
15 | defaultValue: 0);
16 | }
17 |
18 | protected override void Down(MigrationBuilder migrationBuilder)
19 | {
20 | migrationBuilder.DropColumn(
21 | name: "Quality",
22 | table: "FileInfo");
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/20170129135547_MyFirstMigration.Designer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using ConsoleApplication1;
7 | using Microsoft.EntityFrameworkCore.Specification.Tests;
8 |
9 | namespace ConsoleApplication1.Migrations
10 | {
11 | [DbContext(typeof(Issue398Test.BloggingContext))]
12 | [Migration("20170129135547_MyFirstMigration")]
13 | partial class MyFirstMigration
14 | {
15 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
16 | {
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "1.2.0-preview1-23235");
19 |
20 | modelBuilder.Entity("ConsoleApplication1.Blog", b =>
21 | {
22 | b.Property("BlogId")
23 | .ValueGeneratedOnAdd();
24 |
25 | b.Property("Url");
26 |
27 | b.HasKey("BlogId");
28 |
29 | b.ToTable("Blogs");
30 | });
31 |
32 | modelBuilder.Entity("ConsoleApplication1.Post", b =>
33 | {
34 | b.Property("PostId")
35 | .ValueGeneratedOnAdd();
36 |
37 | b.Property("BlogId");
38 |
39 | b.Property("Content");
40 |
41 | b.Property("Title");
42 |
43 | b.HasKey("PostId");
44 |
45 | b.HasIndex("BlogId");
46 |
47 | b.ToTable("Posts");
48 | });
49 |
50 | modelBuilder.Entity("ConsoleApplication1.Post", b =>
51 | {
52 | b.HasOne("ConsoleApplication1.Blog", "Blog")
53 | .WithMany("Posts")
54 | .HasForeignKey("BlogId")
55 | .OnDelete(DeleteBehavior.Cascade);
56 | });
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/20170129135547_MyFirstMigration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore.Migrations;
4 |
5 | namespace ConsoleApplication1.Migrations
6 | {
7 | public partial class MyFirstMigration : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Blogs",
13 | columns: table => new
14 | {
15 | BlogId = table.Column(nullable: false)
16 | .Annotation("SqlCe:ValueGeneration", "True"),
17 | Url = table.Column(nullable: true)
18 | },
19 | constraints: table =>
20 | {
21 | table.PrimaryKey("PK_Blogs", x => x.BlogId);
22 | });
23 |
24 | migrationBuilder.CreateTable(
25 | name: "Posts",
26 | columns: table => new
27 | {
28 | PostId = table.Column(nullable: false)
29 | .Annotation("SqlCe:ValueGeneration", "True"),
30 | BlogId = table.Column(nullable: false),
31 | Content = table.Column(nullable: true),
32 | Title = table.Column(nullable: true)
33 | },
34 | constraints: table =>
35 | {
36 | table.PrimaryKey("PK_Posts", x => x.PostId);
37 | table.ForeignKey(
38 | name: "FK_Posts_Blogs_BlogId",
39 | column: x => x.BlogId,
40 | principalTable: "Blogs",
41 | principalColumn: "BlogId",
42 | onDelete: ReferentialAction.Cascade);
43 | });
44 |
45 | migrationBuilder.CreateIndex(
46 | name: "IX_Posts_BlogId",
47 | table: "Posts",
48 | column: "BlogId");
49 | }
50 |
51 | protected override void Down(MigrationBuilder migrationBuilder)
52 | {
53 | migrationBuilder.DropTable(
54 | name: "Posts");
55 |
56 | migrationBuilder.DropTable(
57 | name: "Blogs");
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/20170129140932_MySecondMigration.Designer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using ConsoleApplication1;
7 | using Microsoft.EntityFrameworkCore.Specification.Tests;
8 |
9 | namespace ConsoleApplication1.Migrations
10 | {
11 | [DbContext(typeof(Issue398Test.BloggingContext))]
12 | [Migration("20170129140932_MySecondMigration")]
13 | partial class MySecondMigration
14 | {
15 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
16 | {
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "1.2.0-preview1-23235");
19 |
20 | modelBuilder.Entity("ConsoleApplication1.Blog", b =>
21 | {
22 | b.Property("BlogId")
23 | .ValueGeneratedOnAdd();
24 |
25 | b.Property("Url");
26 |
27 | b.HasKey("BlogId");
28 |
29 | b.ToTable("Blogs");
30 | });
31 |
32 | modelBuilder.Entity("ConsoleApplication1.Post", b =>
33 | {
34 | b.Property("PostId")
35 | .ValueGeneratedOnAdd();
36 |
37 | b.Property("BlogId");
38 |
39 | b.Property("Content");
40 |
41 | b.Property("Title");
42 |
43 | b.HasKey("PostId");
44 |
45 | b.HasIndex("BlogId")
46 | .HasAnnotation("SqlCe:Name", "NewIndex");
47 |
48 | b.ToTable("Posts");
49 | });
50 |
51 | modelBuilder.Entity("ConsoleApplication1.Post", b =>
52 | {
53 | b.HasOne("ConsoleApplication1.Blog", "Blog")
54 | .WithMany("Posts")
55 | .HasForeignKey("BlogId")
56 | .OnDelete(DeleteBehavior.Cascade);
57 | });
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/20170129140932_MySecondMigration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.EntityFrameworkCore.Migrations;
4 |
5 | namespace ConsoleApplication1.Migrations
6 | {
7 | public partial class MySecondMigration : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.RenameIndex(
12 | name: "IX_Posts_BlogId",
13 | table: "Posts",
14 | newName: "NewIndex");
15 | }
16 |
17 | protected override void Down(MigrationBuilder migrationBuilder)
18 | {
19 | migrationBuilder.RenameIndex(
20 | name: "NewIndex",
21 | table: "Posts",
22 | newName: "IX_Posts_BlogId");
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/BloggingContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using ConsoleApplication1;
7 | using Microsoft.EntityFrameworkCore.Specification.Tests;
8 |
9 | namespace ConsoleApplication1.Migrations
10 | {
11 | [DbContext(typeof(Issue398Test.BloggingContext))]
12 | partial class BloggingContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | modelBuilder
17 | .HasAnnotation("ProductVersion", "1.2.0-preview1-23235");
18 |
19 | modelBuilder.Entity("ConsoleApplication1.Blog", b =>
20 | {
21 | b.Property("BlogId")
22 | .ValueGeneratedOnAdd();
23 |
24 | b.Property("Url");
25 |
26 | b.HasKey("BlogId");
27 |
28 | b.ToTable("Blogs");
29 | });
30 |
31 | modelBuilder.Entity("ConsoleApplication1.Post", b =>
32 | {
33 | b.Property("PostId")
34 | .ValueGeneratedOnAdd();
35 |
36 | b.Property("BlogId");
37 |
38 | b.Property("Content");
39 |
40 | b.Property("Title");
41 |
42 | b.HasKey("PostId");
43 |
44 | b.HasIndex("BlogId")
45 | .HasAnnotation("SqlCe:Name", "NewIndex");
46 |
47 | b.ToTable("Posts");
48 | });
49 |
50 | modelBuilder.Entity("ConsoleApplication1.Post", b =>
51 | {
52 | b.HasOne("ConsoleApplication1.Blog", "Blog")
53 | .WithMany("Posts")
54 | .HasForeignKey("BlogId")
55 | .OnDelete(DeleteBehavior.Cascade);
56 | });
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Migrations/TiffFilesContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Infrastructure;
3 | using Microsoft.EntityFrameworkCore.Specification.Tests;
4 |
5 | namespace ConsoleApplication3.Migrations
6 | {
7 | [DbContext(typeof(Issue305Test.TiffFilesContext))]
8 | partial class TiffFilesContextModelSnapshot : ModelSnapshot
9 | {
10 | protected override void BuildModel(ModelBuilder modelBuilder)
11 | {
12 | modelBuilder
13 | .HasAnnotation("ProductVersion", "1.0.0");
14 |
15 | modelBuilder.Entity("ConsoleApplication3.FileInfo", b =>
16 | {
17 | b.ToTable("FileInfo");
18 |
19 | b.Property("FileInfoId")
20 | .ValueGeneratedOnAdd();
21 |
22 | b.Property("BlindedName");
23 |
24 | b.Property("ContainsSynapse");
25 |
26 | b.Property("Path")
27 | .IsRequired();
28 |
29 | b.Property("Quality");
30 |
31 | b.HasKey("FileInfoId");
32 | });
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/MigrationsSqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 | using System.IO;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class MigrationsSqlCeFixture : MigrationsFixtureBase
7 | {
8 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
9 |
10 | public MigrationsSqlCeFixture()
11 | {
12 | if (File.Exists("TransactionSuppressed.sdf"))
13 | {
14 | File.Delete("TransactionSuppressed.sdf");
15 | }
16 | }
17 |
18 | public override MigrationsContext CreateContext()
19 | {
20 | var options = AddOptions(
21 | new DbContextOptionsBuilder()
22 | .UseSqlCe(TestStore.ConnectionString, b => b.ApplyConfiguration()))
23 | .UseInternalServiceProvider(ServiceProvider)
24 | .Options;
25 | return new MigrationsContext(options);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/MonsterFixupChangedChangingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Diagnostics;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class MonsterFixupChangedChangingSqlCeTest :
7 | MonsterFixupTestBase
8 | {
9 | public MonsterFixupChangedChangingSqlCeTest(MonsterFixupChangedChangingSqlCeFixture fixture)
10 | : base(fixture)
11 | {
12 | }
13 |
14 | public class MonsterFixupChangedChangingSqlCeFixture : MonsterFixupChangedChangingFixtureBase
15 | {
16 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
17 |
18 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
19 | => base.AddOptions(builder).ConfigureWarnings(w => w.Log(RelationalEventId.QueryClientEvaluationWarning));
20 |
21 | protected override void OnModelCreating(
22 | ModelBuilder builder)
23 | {
24 | base.OnModelCreating(builder);
25 |
26 | builder.Entity().HasKey(e => e.MessageId);
27 |
28 | builder.Entity()
29 | .OwnsOne(c => (TDimensions)c.Dimensions, db =>
30 | {
31 | db.Property(d => d.Depth).HasColumnType("decimal(18,2)");
32 | db.Property(d => d.Width).HasColumnType("decimal(18,2)");
33 | db.Property(d => d.Height).HasColumnType("decimal(18,2)");
34 | });
35 |
36 | builder.Entity().HasKey(e => e.PhotoId);
37 | builder.Entity().HasKey(e => e.ReviewId);
38 |
39 | builder.Entity()
40 | .OwnsOne(c => (TDimensions)c.Dimensions, db =>
41 | {
42 | db.Property(d => d.Depth).HasColumnType("decimal(18,2)");
43 | db.Property(d => d.Width).HasColumnType("decimal(18,2)");
44 | db.Property(d => d.Height).HasColumnType("decimal(18,2)");
45 | });
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/NorthwindEF7.sdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/test/EntityFramework.SqlServerCompact.FunctionalTests/NorthwindEF7.sdf
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/NotificationEntitiesSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 | namespace Microsoft.EntityFrameworkCore
3 | {
4 | public class NotificationEntitiesSqlCeTest
5 | : NotificationEntitiesTestBase
6 | {
7 | public NotificationEntitiesSqlCeTest(NotificationEntitiesSqlCeFixture fixture)
8 | : base(fixture)
9 | {
10 | }
11 |
12 | public class NotificationEntitiesSqlCeFixture : NotificationEntitiesFixtureBase
13 | {
14 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/OptimisticConcurrencySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 | using Microsoft.EntityFrameworkCore.Storage;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class OptimisticConcurrencySqlCeTest : OptimisticConcurrencyTestBase
7 | {
8 | public OptimisticConcurrencySqlCeTest(F1SqlCeFixture fixture)
9 | : base(fixture)
10 | {
11 | }
12 |
13 | protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
14 | => facade.UseTransaction(transaction.GetDbTransaction());
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("EntityFramework.SqlServerCompact.FunctionalTests")]
4 | [assembly: AssemblyProduct("EntityFramework.SqlServerCompact.FunctionalTests")]
5 |
6 | [assembly: AssemblyVersion("1.0.0.0")]
7 | [assembly: AssemblyFileVersion("1.0.0.0")]
8 | [assembly: AssemblyInformationalVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/PropertyEntrySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 | using Xunit.Abstractions;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class PropertyEntrySqlCeTest : PropertyEntryTestBase
7 | {
8 | public PropertyEntrySqlCeTest(F1SqlCeFixture fixture, ITestOutputHelper testOutputHelper)
9 | : base(fixture)
10 | {
11 | fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
12 | }
13 |
14 | [Fact(Skip="Logged issue https://github.com/aspnet/EntityFrameworkCore/issues/11285")]
15 | public override void Property_entry_original_value_is_set()
16 | {
17 | base.Property_entry_original_value_is_set();
18 |
19 | Assert.Contains(
20 | @"SELECT TOP(1) [e].[Id], [e].[EngineSupplierId], [e].[Name], [e].[Id], [e].[StorageLocation_Latitude], [e].[StorageLocation_Longitude]
21 | FROM [Engines] AS [e]",
22 | Sql);
23 |
24 | Assert.Contains(
25 | @"UPDATE [Engines] SET [Name] = @p0
26 | WHERE [Id] = @p1 AND [EngineSupplierId] = @p2 AND [Name] = @p3",
27 | Sql);
28 | }
29 |
30 | private string Sql => Fixture.TestSqlLoggerFactory.Sql;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/PropertyValuesSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore
4 | {
5 | public class PropertyValuesSqlCeTest
6 | : PropertyValuesTestBase
7 | {
8 | public PropertyValuesSqlCeTest(PropertyValuesSqlCeFixture fixture)
9 | : base(fixture)
10 | {
11 | }
12 |
13 | public class PropertyValuesSqlCeFixture : PropertyValuesFixtureBase
14 | {
15 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
16 |
17 | protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
18 | {
19 | base.OnModelCreating(modelBuilder, context);
20 |
21 | modelBuilder.Entity()
22 | .Property(b => b.Value).HasColumnType("decimal(18,2)");
23 |
24 | modelBuilder.Entity()
25 | .Property(ce => ce.LeaveBalance).HasColumnType("decimal(18,2)");
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/AsNoTrackingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class AsNoTrackingSqlCeTest : AsNoTrackingTestBase>
6 | {
7 | public AsNoTrackingSqlCeTest(NorthwindQuerySqlCeFixture fixture)
8 | : base(fixture)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/AsTrackingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class AsTrackingSqlCeTest : AsTrackingTestBase>
6 | {
7 | public AsTrackingSqlCeTest(NorthwindQuerySqlCeFixture fixture)
8 | : base(fixture)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/AsyncFromSqlQuerySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class AsyncFromSqlQuerySqlCeTest : AsyncFromSqlQueryTestBase>
6 | {
7 | public AsyncFromSqlQuerySqlCeTest(NorthwindQuerySqlCeFixture fixture)
8 | : base(fixture)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/AsyncGearsOfWarSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Xunit.Abstractions;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class AsyncGearsOfWarQuerySqlCeTest : AsyncGearsOfWarQueryTestBase
6 | {
7 | public AsyncGearsOfWarQuerySqlCeTest(GearsOfWarQuerySqlCeFixture fixture, ITestOutputHelper testOutputHelper)
8 | : base(fixture)
9 | {
10 | Fixture.TestSqlLoggerFactory.Clear();
11 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/AsyncGroupByQuerySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 | using Xunit;
4 | using Xunit.Abstractions;
5 |
6 | namespace Microsoft.EntityFrameworkCore.Query
7 | {
8 | public class AsyncGroupByQuerySqlCeTest : AsyncGroupByQueryTestBase>
9 | {
10 | // ReSharper disable once UnusedParameter.Local
11 | public AsyncGroupByQuerySqlCeTest(NorthwindQuerySqlCeFixture fixture, ITestOutputHelper testOutputHelper)
12 | : base(fixture)
13 | {
14 | Fixture.TestSqlLoggerFactory.Clear();
15 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
16 | }
17 |
18 | [Fact(Skip= "SQLCE limitation")]
19 | public override async Task Select_nested_collection_with_groupby()
20 | {
21 | await base.Select_nested_collection_with_groupby();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/AsyncIncludeSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 | using Xunit;
4 | using Xunit.Abstractions;
5 |
6 | namespace Microsoft.EntityFrameworkCore.Query
7 | {
8 | public class AsyncIncludeSqlCeTest : IncludeAsyncTestBase
9 | {
10 | public AsyncIncludeSqlCeTest(IncludeSqlCeFixture fixture, ITestOutputHelper testOutputHelper)
11 | : base(fixture)
12 | {
13 | //fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
14 | }
15 |
16 | [Fact(Skip = "SQLCE limitation")]
17 | public override Task Include_collection_order_by_subquery()
18 | {
19 | return base.Include_collection_order_by_subquery();
20 | }
21 |
22 | [SqlServerCondition(SqlServerCondition.SupportsOffset)]
23 | public override Task Include_duplicate_reference()
24 | {
25 | return base.Include_duplicate_reference();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/ChangeTrackingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestModels.Northwind;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class ChangeTrackingSqlCeTest : ChangeTrackingTestBase>
7 | {
8 | public ChangeTrackingSqlCeTest(NorthwindQuerySqlCeFixture fixture)
9 | : base(fixture)
10 | {
11 | }
12 |
13 | protected override NorthwindContext CreateNoTrackingContext()
14 | => new NorthwindRelationalContext(
15 | new DbContextOptionsBuilder(Fixture.CreateOptions())
16 | .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking).Options);
17 | }
18 | }
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/ComplexNavigationsQuerySqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class ComplexNavigationsQuerySqlCeFixture : ComplexNavigationsQueryRelationalFixtureBase
6 | {
7 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
8 | }
9 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class ComplexNavigationsWeakQuerySqlCeFixture : ComplexNavigationsWeakQueryRelationalFixtureBase
6 | {
7 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/FiltersInheritanceSqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.EntityFrameworkCore.Query
2 | {
3 | public class FiltersInheritanceSqlCeFixture : InheritanceSqlCeFixture
4 | {
5 | protected override bool EnableFilters => true;
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 | using Xunit.Abstractions;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class GearsOfWarFromSqlQuerySqlCeTest : GearsOfWarFromSqlQueryTestBase
7 | {
8 | public GearsOfWarFromSqlQuerySqlCeTest(GearsOfWarQuerySqlCeFixture fixture, ITestOutputHelper testOutputHelper)
9 | : base(fixture)
10 | {
11 | fixture.TestSqlLoggerFactory.Clear();
12 | }
13 |
14 | public override void From_sql_queryable_simple_columns_out_of_order()
15 | {
16 | base.From_sql_queryable_simple_columns_out_of_order();
17 |
18 | Assert.Equal(
19 | @"SELECT ""Id"", ""Name"", ""IsAutomatic"", ""AmmunitionType"", ""OwnerFullName"", ""SynergyWithId"" FROM ""Weapons"" ORDER BY ""Name""",
20 | Sql);
21 | }
22 |
23 | protected override void ClearLog()
24 | => Fixture.TestSqlLoggerFactory.Clear();
25 |
26 | private string Sql => Fixture.TestSqlLoggerFactory.Sql;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/GearsOfWarQuerySqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class GearsOfWarQuerySqlCeFixture : GearsOfWarQueryRelationalFixture
7 | {
8 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
9 |
10 | protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
11 | {
12 | base.OnModelCreating(modelBuilder, context);
13 |
14 | modelBuilder.Entity().Property(g => g.Location).HasColumnType("nvarchar(100)");
15 | modelBuilder.Entity().Ignore(m => m.Timeline);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/GroupBySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 | using Xunit;
4 | using Xunit.Abstractions;
5 |
6 | namespace Microsoft.EntityFrameworkCore.Query
7 | {
8 | public class GroupByQuerySqlCeTest : GroupByQueryTestBase>
9 | {
10 | // ReSharper disable once UnusedParameter.Local
11 | public GroupByQuerySqlCeTest(NorthwindQuerySqlCeFixture fixture, ITestOutputHelper testOutputHelper)
12 | : base(fixture)
13 | {
14 | Fixture.TestSqlLoggerFactory.Clear();
15 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
16 | }
17 |
18 | [Theory(Skip = "SQLCE limitation")]
19 | public override async Task GroupBy_OrderBy_count_Select_sum(bool isAsync)
20 | {
21 | await base.GroupBy_OrderBy_count_Select_sum(isAsync);
22 | }
23 |
24 | [Theory(Skip = "SQLCE limitation")]
25 | public override void Select_nested_collection_with_groupby()
26 | {
27 | base.Select_nested_collection_with_groupby();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/IncludeOneToOneSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 | using Microsoft.Extensions.DependencyInjection;
3 | using Microsoft.Extensions.Logging;
4 | using System.Linq;
5 | using Xunit;
6 | using Xunit.Abstractions;
7 |
8 | namespace Microsoft.EntityFrameworkCore.Query
9 | {
10 | public class IncludeOneToOneSqlCeTest : IncludeOneToOneTestBase
11 | {
12 | public IncludeOneToOneSqlCeTest(OneToOneQuerySqlCeFixture fixture, ITestOutputHelper testOutputHelper)
13 | : base(fixture)
14 | {
15 | fixture.TestSqlLoggerFactory.Clear();
16 | }
17 |
18 | public override void Include_person()
19 | {
20 | base.Include_person();
21 |
22 | Assert.Equal(
23 | @"SELECT [a].[Id], [a].[City], [a].[Street], [a.Resident].[Id], [a.Resident].[Name]
24 | FROM [Address] AS [a]
25 | INNER JOIN [Person] AS [a.Resident] ON [a].[Id] = [a.Resident].[Id]",
26 | Sql);
27 | }
28 |
29 | public override void Include_person_shadow()
30 | {
31 | base.Include_person_shadow();
32 |
33 | Assert.Equal(
34 | @"SELECT [a].[Id], [a].[City], [a].[PersonId], [a].[Street], [a.Resident].[Id], [a.Resident].[Name]
35 | FROM [Address2] AS [a]
36 | INNER JOIN [Person2] AS [a.Resident] ON [a].[PersonId] = [a.Resident].[Id]",
37 | Sql);
38 | }
39 |
40 | public override void Include_address()
41 | {
42 | base.Include_address();
43 |
44 | Assert.Equal(
45 | @"SELECT [p].[Id], [p].[Name], [p.Address].[Id], [p.Address].[City], [p.Address].[Street]
46 | FROM [Person] AS [p]
47 | LEFT JOIN [Address] AS [p.Address] ON [p].[Id] = [p.Address].[Id]",
48 | Sql);
49 | }
50 |
51 | public override void Include_address_shadow()
52 | {
53 | base.Include_address_shadow();
54 |
55 | Assert.Equal(
56 | @"SELECT [p].[Id], [p].[Name], [p.Address].[Id], [p.Address].[City], [p.Address].[PersonId], [p.Address].[Street]
57 | FROM [Person2] AS [p]
58 | LEFT JOIN [Address2] AS [p.Address] ON [p].[Id] = [p.Address].[PersonId]",
59 | Sql);
60 | }
61 |
62 | private string Sql => Fixture.TestSqlLoggerFactory.SqlStatements.Last();
63 |
64 | public class OneToOneQuerySqlCeFixture : OneToOneQueryFixtureBase
65 | {
66 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
67 | public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/IncludeSqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Diagnostics;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class IncludeSqlCeFixture : NorthwindQuerySqlCeFixture
7 | {
8 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
9 | => base.AddOptions(builder).ConfigureWarnings(c => c.Log(CoreEventId.IncludeIgnoredWarning));
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/InheritanceRelationshipsQuerySqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class InheritanceRelationshipsQuerySqlCeFixture : InheritanceRelationshipsQueryRelationalFixture
6 | {
7 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/InheritanceSqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class InheritanceSqlCeFixture : InheritanceRelationalFixture
6 | {
7 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
8 | }
9 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/MappingQuerySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Query;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 | using System;
4 | using Xunit;
5 |
6 | namespace Microsoft.EntityFrameworkCore.Specification.Tests
7 | {
8 | public class MappingQuerySqlCeTest : MappingQueryTestBase
9 | {
10 | public override void All_customers()
11 | {
12 | base.All_customers();
13 |
14 | Assert.Equal(
15 | @"SELECT [c].[CustomerID], [c].[CompanyName]
16 | FROM [Customers] AS [c]",
17 | Sql);
18 | }
19 |
20 | public override void All_employees()
21 | {
22 | base.All_employees();
23 |
24 | Assert.Equal(
25 | @"SELECT [e].[EmployeeID], [e].[City]
26 | FROM [Employees] AS [e]",
27 | Sql);
28 | }
29 |
30 | public override void All_orders()
31 | {
32 | base.All_orders();
33 |
34 | Assert.Equal(
35 | @"SELECT [o].[OrderID], [o].[ShipVia]
36 | FROM [Orders] AS [o]",
37 | Sql);
38 | }
39 |
40 | public override void Project_nullable_enum()
41 | {
42 | base.Project_nullable_enum();
43 |
44 | Assert.Equal(
45 | @"SELECT [o].[ShipVia]
46 | FROM [Orders] AS [o]",
47 | Sql);
48 | }
49 |
50 | public MappingQuerySqlCeTest(MappingQuerySqlCeFixture fixture)
51 | : base(fixture)
52 | {
53 | Fixture.TestSqlLoggerFactory.Clear();
54 | }
55 |
56 | private const string FileLineEnding = @"
57 | ";
58 | private string Sql => Fixture.TestSqlLoggerFactory.Sql;
59 |
60 | public class MappingQuerySqlCeFixture : MappingQueryFixtureBase
61 | {
62 | protected override ITestStoreFactory TestStoreFactory => SqlCeNorthwindTestStoreFactory.Instance;
63 |
64 | protected override string DatabaseSchema { get; } = null;
65 |
66 | protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
67 | {
68 | base.OnModelCreating(modelBuilder, context);
69 |
70 | modelBuilder.Entity(e =>
71 | {
72 | e.Property(c => c.CompanyName2).Metadata.SqlCe().ColumnName = "CompanyName";
73 | e.Metadata.SqlCe().TableName = "Customers";
74 | });
75 |
76 | modelBuilder.Entity()
77 | .Property(c => c.EmployeeID)
78 | .HasColumnType("int");
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/NorthwindQuerySqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 | using Microsoft.EntityFrameworkCore.TestModels.Northwind;
3 | using Microsoft.EntityFrameworkCore.TestUtilities;
4 |
5 | namespace Microsoft.EntityFrameworkCore.Query
6 | {
7 | public class NorthwindQuerySqlCeFixture : NorthwindQueryRelationalFixture
8 | where TModelCustomizer : IModelCustomizer, new()
9 | {
10 | protected override ITestStoreFactory TestStoreFactory => SqlCeNorthwindTestStoreFactory.Instance;
11 |
12 | protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
13 | {
14 | base.OnModelCreating(modelBuilder, context);
15 |
16 | modelBuilder.Entity()
17 | .Property(c => c.CustomerID)
18 | .HasColumnType("nchar(5)");
19 |
20 | modelBuilder.Entity(
21 | b =>
22 | {
23 | b.Property(c => c.EmployeeID).HasColumnType("int");
24 | b.Property(c => c.ReportsTo).HasColumnType("int");
25 | });
26 |
27 | modelBuilder.Entity()
28 | .Property(o => o.EmployeeID)
29 | .HasColumnType("int");
30 |
31 | modelBuilder.Entity()
32 | .Property(od => od.UnitPrice)
33 | .HasColumnType("money");
34 |
35 | modelBuilder.Entity(
36 | b =>
37 | {
38 | b.Property(p => p.UnitPrice).HasColumnType("money");
39 | b.Property(p => p.UnitsInStock).HasColumnType("smallint");
40 | });
41 |
42 | modelBuilder.Entity()
43 | .Property(p => p.UnitPrice)
44 | .HasColumnType("money");
45 | }
46 |
47 | protected override void Seed(NorthwindContext context)
48 | {
49 | //base.Seed(context);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/NorthwindQueryWithForcedClientEvalSqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class NorthwindQueryWithForcedClientEvalSqlCeFixture : NorthwindQuerySqlCeFixture
7 | {
8 | protected override ITestStoreFactory TestStoreFactory => SqlCeNorthwindTestStoreFactory.Instance;
9 |
10 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
11 | {
12 | var optionsBuilder = base.AddOptions(builder);
13 | new SqlCeDbContextOptionsBuilder(optionsBuilder).UseClientEvalForUnsupportedSqlConstructs(true);
14 | return optionsBuilder;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/NullKeysSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class NullKeysSqlCeTest : NullKeysTestBase
6 | {
7 | public NullKeysSqlCeTest(NullKeysSqlCeFixture fixture)
8 | : base(fixture)
9 | {
10 | }
11 |
12 | public class NullKeysSqlCeFixture : NullKeysFixtureBase
13 | {
14 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/NullSemanticsQuerySqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore.Query
4 | {
5 | public class NullSemanticsQuerySqlCeFixture : NullSemanticsQueryRelationalFixture
6 | {
7 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
8 | }
9 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/OwnedQuerySqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 | using Xunit;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class OwnedQuerySqlCeTest : RelationalOwnedQueryTestBase
7 | {
8 | public OwnedQuerySqlCeTest(OwnedQuerySqlCeFixture fixture)
9 | : base(fixture)
10 | {
11 | //fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
12 | }
13 |
14 | [Fact(Skip = "SQLCE limitation")]
15 | public override void Navigation_rewrite_on_owned_collection()
16 | {
17 | base.Navigation_rewrite_on_owned_collection();
18 | }
19 |
20 | [Fact(Skip = "SQLCE limitation")]
21 | public override void Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection_count()
22 | {
23 | base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection_count();
24 | }
25 |
26 | private void AssertSql(params string[] expected)
27 | => Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
28 |
29 | public class OwnedQuerySqlCeFixture : RelationalOwnedQueryFixture
30 | {
31 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
32 |
33 | protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
34 | {
35 | modelBuilder.Entity()
36 | .Property(p => p.Id)
37 | .ValueGeneratedNever();
38 |
39 | modelBuilder.Entity()
40 | .Property(p => p.Id)
41 | .ValueGeneratedNever();
42 |
43 | modelBuilder.Entity()
44 | .Property(p => p.Id)
45 | .ValueGeneratedNever();
46 |
47 | modelBuilder.Entity()
48 | .Property(p => p.Id)
49 | .ValueGeneratedNever();
50 |
51 | modelBuilder.Entity()
52 | .Property(p => p.Id)
53 | .ValueGeneratedNever();
54 |
55 | modelBuilder.Entity()
56 | .Property(p => p.Id)
57 | .ValueGeneratedNever();
58 |
59 | base.OnModelCreating(modelBuilder, context);
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/QueryFilterFuncletizationSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 | using Xunit.Abstractions;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class QueryFilterFuncletizationSqlCeTest
7 | : QueryFilterFuncletizationTestBase
8 | {
9 | public QueryFilterFuncletizationSqlCeTest(
10 | QueryFilterFuncletizationSqlCeFixture fixture, ITestOutputHelper testOutputHelper)
11 | : base(fixture)
12 | {
13 | Fixture.TestSqlLoggerFactory.Clear();
14 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
15 | }
16 |
17 | public class QueryFilterFuncletizationSqlCeFixture : QueryFilterFuncletizationRelationalFixture
18 | {
19 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/QueryNavigationsWithForcedClientEvalSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xunit;
3 | using Xunit.Abstractions;
4 | using Microsoft.EntityFrameworkCore.TestUtilities;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.EntityFrameworkCore.Query
8 | {
9 |
10 | public class QueryNavigationsWithForcedClientEvalSqlCeTest : QueryNavigationsTestBase
11 | {
12 | public QueryNavigationsWithForcedClientEvalSqlCeTest(
13 | // ReSharper disable once UnusedParameter.Local
14 | NorthwindQueryWithForcedClientEvalSqlCeFixture fixture, ITestOutputHelper testOutputHelper)
15 | : base(fixture)
16 | {
17 | fixture.TestSqlLoggerFactory.Clear();
18 | //TestSqlLoggerFactory.CaptureOutput(testOutputHelper);
19 | }
20 |
21 | //TODO ErikEJ Investigate fails
22 |
23 | [Theory(Skip ="Investigate fail")]
24 | public override Task Where_subquery_on_navigation(bool isAsync)
25 | {
26 | return base.Where_subquery_on_navigation(isAsync);
27 | }
28 |
29 | [Theory(Skip = "Investigate fail")]
30 | public override Task Where_subquery_on_navigation2(bool isAsync)
31 | {
32 | return base.Where_subquery_on_navigation2(isAsync);
33 | }
34 |
35 | [Theory(Skip = "Investigate fail")]
36 | public override Task Project_single_scalar_value_subquery_is_properly_inlined(bool isAsync)
37 | {
38 | return base.Project_single_scalar_value_subquery_is_properly_inlined(isAsync);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/QueryNoClientEvalSqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Diagnostics;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class QueryNoClientEvalSqlCeFixture : NorthwindQuerySqlCeFixture
7 | {
8 | public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
9 | => base.AddOptions(builder).ConfigureWarnings(c => c.Throw(RelationalEventId.QueryClientEvaluationWarning));
10 | }
11 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/QueryNoClientEvalSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.EntityFrameworkCore.Query
2 | {
3 | public class QueryNoClientEvalSqlCeTest : QueryNoClientEvalTestBase
4 | {
5 | public QueryNoClientEvalSqlCeTest(QueryNoClientEvalSqlCeFixture fixture)
6 | : base(fixture)
7 | {
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Query/QueryTaggingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 | using Xunit.Abstractions;
3 |
4 | namespace Microsoft.EntityFrameworkCore.Query
5 | {
6 | public class QueryTaggingSqlCeTest : QueryTaggingTestBase>
7 | {
8 | public QueryTaggingSqlCeTest(
9 | NorthwindQuerySqlCeFixture fixture, ITestOutputHelper testOutputHelper)
10 | : base(fixture)
11 | {
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/Scaffolding/SqlCeDatabaseModelFixture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using Microsoft.EntityFrameworkCore.Internal;
6 | using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
7 | using Microsoft.EntityFrameworkCore.TestUtilities;
8 | using Microsoft.Extensions.Logging;
9 | using EFCore.SqlCe.Scaffolding.Internal;
10 |
11 | namespace Microsoft.EntityFrameworkCore
12 | {
13 | public class SqlCeDatabaseModelFixture : IDisposable
14 | {
15 | public SqlCeDatabaseModelFixture()
16 | {
17 | TestStore = SqlCeTestStore.CreateScratch(true);
18 | }
19 |
20 | public TestSqlLoggerFactory TestDesignLoggerFactory { get; } = new TestSqlLoggerFactory();
21 |
22 | public DatabaseModel CreateModel(List createSql, IEnumerable tables = null, ILogger logger = null)
23 | {
24 | foreach (var sql in createSql)
25 | {
26 | TestStore.ExecuteNonQuery(sql);
27 | }
28 |
29 | return new SqlCeDatabaseModelFactory(
30 | new DiagnosticsLogger(
31 | TestDesignLoggerFactory,
32 | new LoggingOptions(),
33 | new DiagnosticListener("Fake")))
34 | .Create(TestStore.ConnectionString, tables ?? Enumerable.Empty(), Enumerable.Empty());
35 | }
36 |
37 | public IEnumerable Query(string sql, params object[] parameters) => TestStore.Query(sql, parameters);
38 |
39 | public SqlCeTestStore TestStore { get; }
40 |
41 | public void ExecuteNonQuery(string sql) => TestStore.ExecuteNonQuery(sql);
42 |
43 | public void Dispose() => TestStore.Dispose();
44 | }
45 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/SqlCeCommandDisposeTest.cs:
--------------------------------------------------------------------------------
1 | using System.Data.SqlClient;
2 | using System.Data.SqlServerCe;
3 | using Xunit;
4 |
5 | namespace Microsoft.EntityFrameworkCore.Specification.Tests
6 | {
7 | class SqlCeCommandDisposeTest
8 | {
9 | [Fact]
10 | public void SqlCeCommandCannotBeLoggedAfterDispose()
11 | {
12 | var command = new SqlCeCommand();
13 |
14 | command.CommandText = "foo";
15 | command.Parameters.Add(new SqlCeParameter());
16 | command.Dispose();
17 |
18 | Assert.Equal(command.CommandText, string.Empty);
19 | Assert.Equal(command.Parameters.Count, 0);
20 | }
21 |
22 | [Fact]
23 | public void SqlCommandCanBeLoggedAfterDispose()
24 | {
25 | var command = new SqlCommand();
26 |
27 | command.CommandText = "bar";
28 | command.Parameters.Add(new SqlParameter());
29 | command.Dispose();
30 |
31 | Assert.Equal(command.CommandText, "bar");
32 | Assert.Equal(command.Parameters.Count, 1);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/SqlCeComplianceTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using Microsoft.EntityFrameworkCore.Query;
5 |
6 | namespace Microsoft.EntityFrameworkCore
7 | {
8 | public class SqlCeComplianceTest : RelationalComplianceTestBase
9 | {
10 | protected override ICollection IgnoredTestBases { get; } = new HashSet
11 | {
12 | //Unsupported features in SQL Compact:
13 | typeof(AsyncFromSqlSprocQueryTestBase<>),
14 | typeof(FromSqlSprocQueryTestBase<>),
15 | typeof(SqlExecutorTestBase<>),
16 | typeof(SpatialTestBase<>),
17 | typeof(SpatialQueryTestBase<>),
18 | typeof(UdfDbFunctionTestBase<>),
19 |
20 | //No roundtrip of GUIDs with SQL CE
21 | typeof(StoreGeneratedFixupTestBase<>),
22 |
23 | //TODO ErikEJ PR for Core (missing Filler property) #561
24 | typeof(GraphUpdatesTestBase<>)
25 | };
26 |
27 | protected override Assembly TargetAssembly { get; } = typeof(SqlCeComplianceTest).Assembly;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/SqlCeMigrationsTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Infrastructure;
3 | using Microsoft.EntityFrameworkCore.Migrations;
4 | using Microsoft.EntityFrameworkCore.Storage;
5 | using Microsoft.EntityFrameworkCore.TestUtilities;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Xunit;
8 |
9 | namespace Microsoft.EntityFrameworkCore
10 | {
11 | public class SqlCeMigrationsTest
12 | {
13 | [Fact]
14 | public void Empty_Migration_Creates_Database()
15 | {
16 | using (var testDatabase = SqlCeTestStore.CreateScratch(createDatabase: false))
17 | {
18 |
19 | using (var context = CreateContext(testDatabase))
20 | {
21 | context.Database.Migrate();
22 |
23 | Assert.True(context.GetService().Exists());
24 | }
25 | }
26 | }
27 |
28 | private static BloggingContext CreateContext(SqlCeTestStore testStore)
29 | {
30 | var serviceProvider =
31 | new ServiceCollection()
32 | .AddEntityFrameworkSqlCe()
33 | .BuildServiceProvider();
34 |
35 | var optionsBuilder = new DbContextOptionsBuilder();
36 | optionsBuilder
37 | .UseSqlCe(testStore.ConnectionString)
38 | .UseInternalServiceProvider(serviceProvider);
39 |
40 | return new BloggingContext(serviceProvider, optionsBuilder.Options);
41 | }
42 |
43 | private class BloggingContext : DbContext
44 | {
45 | public BloggingContext(IServiceProvider serviceProvider, DbContextOptions options)
46 | : base(options)
47 | {
48 | }
49 |
50 | public DbSet Blogs { get; set; }
51 |
52 | public class Blog
53 | {
54 | public int Id { get; set; }
55 | public string Name { get; set; }
56 | }
57 | }
58 |
59 | [DbContext(typeof(BloggingContext))]
60 | [Migration("00000000000000_Empty")]
61 | public class EmptyMigration : Migration
62 | {
63 | protected override void Up(MigrationBuilder migrationBuilder)
64 | {
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/SqlCeServiceCollectionExtensionsTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 |
3 | namespace Microsoft.EntityFrameworkCore
4 | {
5 | public class SqlCeServiceCollectionExtensionsTest : RelationalServiceCollectionExtensionsTestBase
6 | {
7 | public SqlCeServiceCollectionExtensionsTest()
8 | : base(SqlCeTestHelpers.Instance)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TableSplittingSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestUtilities;
2 | using Xunit.Abstractions;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class TableSplittingSqlCeTest : TableSplittingTestBase
7 | {
8 | public TableSplittingSqlCeTest(ITestOutputHelper testOutputHelper)
9 | : base(testOutputHelper)
10 | {
11 | }
12 |
13 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
14 | }
15 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TestUtilities/DbContextOptionsBuilderExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 |
3 | namespace Microsoft.EntityFrameworkCore.TestUtilities
4 | {
5 | public static class DbContextOptionsBuilderExtensions
6 | {
7 | public static SqlCeDbContextOptionsBuilder ApplyConfiguration(this SqlCeDbContextOptionsBuilder optionsBuilder) => optionsBuilder;
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TestUtilities/SqlCeDatabaseCleaner.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using Microsoft.EntityFrameworkCore.Internal;
3 | using Microsoft.EntityFrameworkCore.Scaffolding;
4 | using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
5 | using Microsoft.Extensions.Logging;
6 | using System;
7 | using EFCore.SqlCe.Scaffolding.Internal;
8 |
9 | namespace Microsoft.EntityFrameworkCore.TestUtilities
10 | {
11 | public class SqlCeDatabaseCleaner : RelationalDatabaseCleaner
12 | {
13 | protected override IDatabaseModelFactory CreateDatabaseModelFactory(ILoggerFactory loggerFactory)
14 | => new SqlCeDatabaseModelFactory(
15 | new DiagnosticsLogger(
16 | loggerFactory,
17 | new LoggingOptions(),
18 | new DiagnosticListener("Fake")));
19 |
20 | protected override bool AcceptIndex(DatabaseIndex index)
21 | => !index.Name.StartsWith("PK_", StringComparison.Ordinal)
22 | && !index.Name.StartsWith("AK_", StringComparison.Ordinal);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TestUtilities/SqlCeDatabaseFacadeTestExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 |
3 | namespace Microsoft.EntityFrameworkCore.TestUtilities
4 | {
5 | public static class SqlCeDatabaseFacadeTestExtensions
6 | {
7 | public static void EnsureClean(this DatabaseFacade databaseFacade)
8 | => new SqlCeDatabaseCleaner().Clean(databaseFacade);
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TestUtilities/SqlCeNorthwindTestStoreFactory.cs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.EntityFrameworkCore.TestUtilities
2 | {
3 | public class SqlCeNorthwindTestStoreFactory : SqlCeTestStoreFactory
4 | {
5 | public const string Name = "Northwind";
6 | public static readonly string NorthwindConnectionString = SqlCeTestStore.CreateConnectionString(Name);
7 | public new static SqlCeNorthwindTestStoreFactory Instance { get; } = new SqlCeNorthwindTestStoreFactory();
8 |
9 | protected SqlCeNorthwindTestStoreFactory()
10 | {
11 | }
12 |
13 | public override TestStore GetOrCreate(string storeName)
14 | => SqlCeTestStore.GetNorthwindStore();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TestUtilities/SqlCeTestHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Data.SqlServerCe;
2 | using Microsoft.Extensions.DependencyInjection;
3 |
4 | namespace Microsoft.EntityFrameworkCore.TestUtilities
5 | {
6 | public class SqlCeTestHelpers : TestHelpers
7 | {
8 | protected SqlCeTestHelpers()
9 | {
10 | }
11 |
12 | public static SqlCeTestHelpers Instance { get; } = new SqlCeTestHelpers();
13 |
14 | public override IServiceCollection AddProviderServices(IServiceCollection services)
15 | => services.AddEntityFrameworkSqlCe();
16 |
17 | protected override void UseProviderOptions(DbContextOptionsBuilder optionsBuilder)
18 | => optionsBuilder.UseSqlCe(new SqlCeConnection("Data Source=DummyDatabase"));
19 | }
20 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TestUtilities/SqlCeTestStoreFactorycs.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 |
3 | namespace Microsoft.EntityFrameworkCore.TestUtilities
4 | {
5 | public class SqlCeTestStoreFactory : RelationalTestStoreFactory
6 | {
7 | public static SqlCeTestStoreFactory Instance { get; } = new SqlCeTestStoreFactory();
8 |
9 | protected SqlCeTestStoreFactory()
10 | {
11 | }
12 |
13 | public override TestStore Create(string storeName)
14 | => SqlCeTestStore.Create(storeName);
15 |
16 | public override TestStore GetOrCreate(string storeName)
17 | => SqlCeTestStore.CreateScratch(true);
18 |
19 | public override IServiceCollection AddProviderServices(IServiceCollection serviceCollection)
20 | => serviceCollection.AddEntityFrameworkSqlCe();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TestUtilities/SqlServerConditionAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.TestUtilities.Xunit;
5 | using System;
6 | using System.Linq;
7 | using Xunit.Sdk;
8 |
9 | namespace Microsoft.EntityFrameworkCore.TestUtilities
10 | {
11 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
12 | [TraitDiscoverer("Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests.Utilities.SqlServerConditionTraitDiscoverer", "Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests")]
13 | public class SqlServerConditionAttribute : Attribute, ITestCondition, ITraitAttribute
14 | {
15 | public SqlServerCondition Conditions { get; set; }
16 |
17 | public SqlServerConditionAttribute(SqlServerCondition conditions)
18 | {
19 | Conditions = conditions;
20 | }
21 |
22 | public bool IsMet
23 | {
24 | get
25 | {
26 | var isMet = true;
27 | if (Conditions.HasFlag(SqlServerCondition.SupportsSequences))
28 | {
29 | return false;
30 | }
31 | if (Conditions.HasFlag(SqlServerCondition.SupportsOffset))
32 | {
33 | return true;
34 | }
35 | if (Conditions.HasFlag(SqlServerCondition.IsSqlAzure))
36 | {
37 | isMet = false;
38 | }
39 | return isMet;
40 | }
41 | }
42 |
43 | public string SkipReason =>
44 | string.Format("The test SQL Server does not meet these conditions: '{0}'"
45 | , string.Join(", ", Enum.GetValues(typeof(SqlServerCondition))
46 | .Cast()
47 | .Where(f => Conditions.HasFlag(f))
48 | .Select(f => Enum.GetName(typeof(SqlServerCondition), f))));
49 | }
50 |
51 | [Flags]
52 | public enum SqlServerCondition
53 | {
54 | SupportsSequences = 1 << 0,
55 | SupportsOffset = 1 << 1,
56 | IsSqlAzure = 1 << 2,
57 | IsNotSqlAzure = 1 << 3,
58 | SupportsMemoryOptimized = 1 << 4,
59 | SupportsAttach = 1 << 5
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/TestUtilities/TestEnvironment.cs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.EntityFrameworkCore.TestUtilities
2 | {
3 | public static class TestEnvironment
4 | {
5 | static TestEnvironment()
6 | {
7 | }
8 |
9 | public static bool? GetFlag(string key) => key == nameof(SqlServerCondition.SupportsOffset);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/UpdatesSqlCeFixture.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.TestModels.UpdatesModel;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 |
4 | namespace Microsoft.EntityFrameworkCore
5 | {
6 | public class UpdatesSqlCeFixture : UpdatesRelationalFixture
7 | {
8 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
9 |
10 | protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
11 | {
12 | base.OnModelCreating(modelBuilder, context);
13 |
14 | modelBuilder.Entity()
15 | .Property(p => p.Price).HasColumnType("decimal(18,2)");
16 |
17 | modelBuilder.Entity()
18 | .Property(p => p.Bytes).HasColumnType("varbinary(8000)");
19 |
20 | modelBuilder.Entity()
21 | .Property(l => l.ProfileId3).HasColumnType("decimal(18,2)");
22 |
23 | modelBuilder.Entity()
24 | .Property(l => l.Id3).HasColumnType("decimal(18,2)");
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/UpdatesSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Microsoft.EntityFrameworkCore.TestModels.UpdatesModel;
3 | using Xunit;
4 | using Xunit.Abstractions;
5 |
6 | namespace Microsoft.EntityFrameworkCore
7 | {
8 | public class UpdatesSqlCeTest : UpdatesRelationalTestBase
9 | {
10 | // ReSharper disable once UnusedParameter.Local
11 | public UpdatesSqlCeTest(UpdatesSqlCeFixture fixture, ITestOutputHelper testOutputHelper)
12 | : base(fixture)
13 | {
14 | //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
15 | Fixture.TestSqlLoggerFactory.Clear();
16 | }
17 |
18 | public override void Save_replaced_principal()
19 | {
20 | base.Save_replaced_principal();
21 |
22 | Fixture.TestSqlLoggerFactory.AssertBaseline(new[]{
23 | @"@p1='78'
24 | @p0='New Category' (Size = 4000)
25 |
26 | UPDATE [Categories] SET [Name] = @p0
27 | WHERE [Id] = @p1"
28 | }, assertOrder: false);
29 | }
30 |
31 | public override void Identifiers_are_generated_correctly()
32 | {
33 | using (var context = CreateContext())
34 | {
35 | var entityType = context.Model.FindEntityType(typeof(
36 | LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectly));
37 | Assert.Equal("LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorking~", entityType.Relational().TableName);
38 | Assert.Equal("PK_LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWork~", entityType.GetKeys().Single().Relational().Name);
39 | Assert.Equal("FK_LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWork~", entityType.GetForeignKeys().Single().Relational().Name);
40 | Assert.Equal("IX_LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWork~", entityType.GetIndexes().Single().Relational().Name);
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.FunctionalTests/WithConstructorsSqlCeTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Infrastructure;
2 | using Microsoft.EntityFrameworkCore.Storage;
3 | using Microsoft.EntityFrameworkCore.TestUtilities;
4 | using Xunit;
5 |
6 | namespace Microsoft.EntityFrameworkCore
7 | {
8 | public class WithConstructorsSqlCeTest : WithConstructorsTestBase
9 | {
10 | public WithConstructorsSqlCeTest(WithConstructorsSqlCeFixture fixture)
11 | : base(fixture)
12 | {
13 | }
14 |
15 | [Fact(Skip="SQLCE does not support views")]
16 | public override void Query_with_query_type()
17 | {
18 | base.Query_with_query_type();
19 | }
20 |
21 | protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
22 | => facade.UseTransaction(transaction.GetDbTransaction());
23 |
24 | public class WithConstructorsSqlCeFixture : WithConstructorsFixtureBase
25 | {
26 | protected override ITestStoreFactory TestStoreFactory => SqlCeTestStoreFactory.Instance;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/ApiConsistencyTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using EFCore.SqlCe.Storage.Internal;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 | using Microsoft.Extensions.DependencyInjection;
7 |
8 | namespace Microsoft.EntityFrameworkCore
9 | {
10 | public class ApiConsistencyTest : ApiConsistencyTestBase
11 | {
12 | private static readonly Type[] _fluentApiTypes =
13 | {
14 | typeof(SqlCeDbContextOptionsBuilder),
15 | typeof(SqlCeDbContextOptionsExtensions),
16 | typeof(SqlCeMetadataExtensions),
17 | typeof(SqlCeServiceCollectionExtensions)
18 | };
19 |
20 | protected override IEnumerable FluentApiTypes => _fluentApiTypes;
21 |
22 | protected override void AddServices(ServiceCollection serviceCollection)
23 | {
24 | serviceCollection.AddEntityFrameworkSqlCe();
25 | }
26 |
27 | protected override Assembly TargetAssembly => typeof(SqlCeDatabaseConnection).GetTypeInfo().Assembly;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Design/DesignTimeProvidersServicesTest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Reflection;
6 | using Xunit;
7 |
8 | namespace Microsoft.EntityFrameworkCore.Design
9 | {
10 | public abstract class DesignTimeProviderServicesTest
11 | {
12 | protected abstract Assembly GetRuntimeAssembly();
13 | protected abstract Type GetDesignTimeServicesType();
14 |
15 | [Fact]
16 | public void Ensure_assmebly_identity_matches()
17 | {
18 | var runtimeAssembly = GetRuntimeAssembly();
19 | var dtAttribute = runtimeAssembly.GetCustomAttribute();
20 | var dtType = GetDesignTimeServicesType();
21 | Assert.NotNull(dtType);
22 |
23 | Assert.NotNull(dtAttribute);
24 | Assert.Equal(dtType.FullName, dtAttribute.TypeName);
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Design/SqlCeDesignTimeProviderServicesTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using EFCore.SqlCe.Storage.Internal;
4 | using EFCore.SqlCe.Design.Internal;
5 |
6 | namespace Microsoft.EntityFrameworkCore.Design
7 | {
8 | public class SqlCeDesignTimeProviderServicesTest : DesignTimeProviderServicesTest
9 | {
10 | protected override Assembly GetRuntimeAssembly()
11 | => typeof(SqlCeDatabaseConnection).GetTypeInfo().Assembly;
12 |
13 | protected override Type GetDesignTimeServicesType()
14 | => typeof(SqlCeDesignTimeServices);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("EntityFramework.SqlServerCompact.Tests")]
4 | [assembly: AssemblyProduct("EntityFramework.SqlServerCompact.Tests")]
5 | [assembly: AssemblyCopyright("Copyright © 2015")]
6 |
7 | [assembly: AssemblyVersion("1.0.0.0")]
8 | [assembly: AssemblyFileVersion("1.0.0.0")]
9 | [assembly: AssemblyInformationalVersion("1.0.0.0")]
10 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/RelationalModelValidatorTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.EntityFrameworkCore.Tests
8 | {
9 | class RelationalModelValidatorTest
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Scaffolding/SqlCeCodeGeneratorTest.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EFCore.SqlCe.Scaffolding.Internal;
3 | using Xunit;
4 |
5 | namespace Microsoft.EntityFrameworkCore.Scaffolding
6 | {
7 | public class SqlCeCodeGeneratorTest
8 | {
9 | [Fact]
10 | public virtual void Use_provider_method_is_generated_correctly()
11 | {
12 | var codeGenerator = new SqlCeCodeGenerator(new ProviderCodeGeneratorDependencies(
13 | Enumerable.Empty()));
14 |
15 | var result = codeGenerator.GenerateUseProvider("Data Source=Test", providerOptions: null);
16 |
17 | Assert.Equal("UseSqlCe", result.Method);
18 | Assert.Collection(
19 | result.Arguments,
20 | a => Assert.Equal("Data Source=Test", a));
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/SqlCeDataStoreConnectionTest.cs:
--------------------------------------------------------------------------------
1 | using EFCore.SqlCe.Storage.Internal;
2 | using Microsoft.EntityFrameworkCore.Internal;
3 | using Microsoft.EntityFrameworkCore.Storage;
4 | using Microsoft.EntityFrameworkCore.Storage.Internal;
5 | using Microsoft.Extensions.Logging;
6 | using System.Data.SqlServerCe;
7 | using System.Diagnostics;
8 | using Xunit;
9 |
10 | namespace Microsoft.EntityFrameworkCore.Tests
11 | {
12 | public class SqlCeDataStoreConnectionTest
13 | {
14 | [Fact]
15 | public void Creates_SQL_ServerCe_connection_string()
16 | {
17 | using (var connection = new SqlCeDatabaseConnection(CreateDependencies()))
18 | {
19 | Assert.IsType(connection.DbConnection);
20 | }
21 | }
22 |
23 | public static RelationalConnectionDependencies CreateDependencies(DbContextOptions options = null)
24 | {
25 | options = options
26 | ?? new DbContextOptionsBuilder()
27 | .UseSqlCe(@"Data Source=C:\data\EF7SQLCE.sdf;")
28 | .Options;
29 |
30 | return new RelationalConnectionDependencies(
31 | options,
32 | new DiagnosticsLogger(
33 | new LoggerFactory(),
34 | new LoggingOptions(),
35 | new DiagnosticListener("FakeDiagnosticListener")),
36 | new DiagnosticsLogger(
37 | new LoggerFactory(),
38 | new LoggingOptions(),
39 | new DiagnosticListener("FakeDiagnosticListener")),
40 | new NamedConnectionStringResolver(options),
41 | new RelationalTransactionFactory(new RelationalTransactionFactoryDependencies()));
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/SqlCeDataStoreSourceTest.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using EFCore.SqlCe.Infrastructure.Internal;
3 | using EFCore.SqlCe.Storage.Internal;
4 | using Microsoft.EntityFrameworkCore.Storage;
5 | using Xunit;
6 |
7 | namespace Microsoft.EntityFrameworkCore.Tests
8 | {
9 | public class SqlCeDataStoreSourceTest
10 | {
11 | [Fact]
12 | public void Is_configured_when_configuration_contains_associated_extension()
13 | {
14 | var optionsBuilder = new DbContextOptionsBuilder();
15 | optionsBuilder.UseSqlCe("Data Source=Crunchie");
16 |
17 | Assert.True(new DatabaseProvider(new DatabaseProviderDependencies()).IsConfigured(optionsBuilder.Options));
18 | }
19 |
20 | [Fact]
21 | public void Is_not_configured_when_configuration_does_not_contain_associated_extension()
22 | {
23 | var optionsBuilder = new DbContextOptionsBuilder();
24 |
25 | Assert.False(new DatabaseProvider(new DatabaseProviderDependencies()).IsConfigured(optionsBuilder.Options));
26 | }
27 |
28 | [Fact]
29 | public void Returns_appropriate_name()
30 | {
31 | Assert.Equal(
32 | typeof(SqlCeDatabaseConnection).GetTypeInfo().Assembly.GetName().Name,
33 | new DatabaseProvider(new DatabaseProviderDependencies()).Name);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/SqlCeTestHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Data.SqlServerCe;
2 | using Microsoft.EntityFrameworkCore.TestUtilities;
3 | using Microsoft.Extensions.DependencyInjection;
4 |
5 | namespace Microsoft.EntityFrameworkCore.Tests
6 | {
7 | public class SqlCeTestHelpers : TestHelpers
8 | {
9 | protected SqlCeTestHelpers()
10 | {
11 | }
12 |
13 | public static SqlCeTestHelpers Instance { get; } = new SqlCeTestHelpers();
14 |
15 | public override IServiceCollection AddProviderServices(IServiceCollection services)
16 | => services.AddEntityFrameworkSqlCe();
17 |
18 | protected override void UseProviderOptions(DbContextOptionsBuilder optionsBuilder)
19 | => optionsBuilder.UseSqlCe(new SqlCeConnection("Data Source=DummyDatabase"));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Storage/SqlCeSqlGenerationHelperTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EFCore.SqlCe.Storage.Internal;
3 | using Xunit;
4 |
5 | namespace Microsoft.EntityFrameworkCore.Storage
6 | {
7 | public class SqlCeSqlGenerationHelperTest : SqlGenerationHelperTestBase
8 | {
9 | public override void BatchSeparator_returns_separator()
10 | {
11 | Assert.Equal("GO" + Environment.NewLine + Environment.NewLine, CreateSqlGenerationHelper().BatchTerminator);
12 | }
13 |
14 | protected override ISqlGenerationHelper CreateSqlGenerationHelper()
15 | => new SqlCeSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies());
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Storage/SqlGenerationHelperTestBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Xunit;
6 |
7 | // Copyright (c) .NET Foundation. All rights reserved.
8 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
9 | namespace Microsoft.EntityFrameworkCore.Storage
10 | {
11 | public abstract class SqlGenerationHelperTestBase
12 | {
13 | [Fact]
14 | public virtual void GenerateParameterName_returns_parameter_name()
15 | {
16 | var name = CreateSqlGenerationHelper().GenerateParameterName("name");
17 | Assert.Equal("@name", name);
18 | }
19 |
20 | [Fact]
21 | public void Default_BatchCommandSeparator_is_semicolon()
22 | {
23 | Assert.Equal(Environment.NewLine, CreateSqlGenerationHelper().StatementTerminator);
24 | }
25 |
26 | [Fact]
27 | public virtual void BatchSeparator_returns_separator()
28 | {
29 | Assert.Equal(string.Empty, CreateSqlGenerationHelper().BatchTerminator);
30 | }
31 |
32 | protected abstract ISqlGenerationHelper CreateSqlGenerationHelper();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/FakeInterceptingLogger.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Diagnostics;
6 | using Microsoft.EntityFrameworkCore.Diagnostics;
7 | using Microsoft.EntityFrameworkCore.Infrastructure;
8 | using Microsoft.Extensions.Logging;
9 |
10 | namespace Microsoft.EntityFrameworkCore.TestUtilities
11 | {
12 | public class FakeDiagnosticsLogger : IDiagnosticsLogger, ILogger
13 | where T : LoggerCategory, new()
14 | {
15 | public ILoggingOptions Options { get; }
16 |
17 | public bool ShouldLogSensitiveData() => false;
18 |
19 | public ILogger Logger => this;
20 |
21 | public DiagnosticSource DiagnosticSource { get; } = new DiagnosticListener("Fake");
22 |
23 | public void Log(
24 | LogLevel logLevel,
25 | EventId eventId,
26 | TState state,
27 | Exception exception,
28 | Func formatter)
29 | {
30 | }
31 |
32 | public bool IsEnabled(LogLevel logLevel) => true;
33 |
34 | public bool IsEnabled(EventId eventId, LogLevel logLevel) => true;
35 |
36 | public WarningBehavior GetLogBehavior(EventId eventId, LogLevel logLevel) => WarningBehavior.Log;
37 |
38 | public IDisposable BeginScope(TState state) => null;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/FakeProvider/FakeDbParameter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Data;
6 | using System.Data.Common;
7 |
8 | namespace Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider
9 | {
10 | public class FakeDbParameter : DbParameter
11 | {
12 | public override string ParameterName { get; set; }
13 |
14 | public override object Value { get; set; }
15 |
16 | public override ParameterDirection Direction { get; set; }
17 |
18 | public static bool DefaultIsNullable = false;
19 | public override bool IsNullable { get; set; } = DefaultIsNullable;
20 |
21 | public static DbType DefaultDbType = DbType.AnsiString;
22 | public override DbType DbType { get; set; } = DefaultDbType;
23 |
24 | public override int Size { get; set; }
25 |
26 | public override string SourceColumn
27 | {
28 | get { throw new NotImplementedException(); }
29 |
30 | set { throw new NotImplementedException(); }
31 | }
32 |
33 | public override bool SourceColumnNullMapping
34 | {
35 | get { throw new NotImplementedException(); }
36 |
37 | set { throw new NotImplementedException(); }
38 | }
39 |
40 | public override void ResetDbType()
41 | {
42 | throw new NotImplementedException();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/FakeProvider/FakeDbTransaction.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Data;
5 | using System.Data.Common;
6 |
7 | namespace Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider
8 | {
9 | public class FakeDbTransaction : DbTransaction
10 | {
11 | public FakeDbTransaction(FakeDbConnection connection, IsolationLevel isolationLevel = IsolationLevel.Unspecified)
12 | {
13 | DbConnection = connection;
14 | IsolationLevel = isolationLevel;
15 | }
16 |
17 | protected override DbConnection DbConnection { get; }
18 |
19 | public override IsolationLevel IsolationLevel { get; }
20 |
21 | public int CommitCount { get; private set; }
22 |
23 | public override void Commit()
24 | {
25 | CommitCount++;
26 | }
27 |
28 | public int RollbackCount { get; private set; }
29 |
30 | public override void Rollback()
31 | {
32 | RollbackCount++;
33 | }
34 |
35 | public int DisposeCount { get; private set; }
36 |
37 | protected override void Dispose(bool disposing)
38 | {
39 | if (disposing)
40 | {
41 | DisposeCount++;
42 |
43 | ((FakeDbConnection)DbConnection).ActiveTransaction = null;
44 | }
45 |
46 | base.Dispose(disposing);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/FakeProvider/FakeRelationalConnection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Data.Common;
6 | using System.Diagnostics;
7 | using Microsoft.EntityFrameworkCore.Infrastructure;
8 | using Microsoft.EntityFrameworkCore.Internal;
9 | using Microsoft.EntityFrameworkCore.Storage;
10 | using Microsoft.EntityFrameworkCore.Storage.Internal;
11 | using Microsoft.Extensions.Logging;
12 |
13 | namespace Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider
14 | {
15 | public class FakeRelationalConnection : RelationalConnection
16 | {
17 | private DbConnection _connection;
18 |
19 | private readonly List _dbConnections = new List();
20 |
21 | public FakeRelationalConnection(IDbContextOptions options)
22 | : base(
23 | new RelationalConnectionDependencies(
24 | options,
25 | new DiagnosticsLogger(
26 | new LoggerFactory(),
27 | new LoggingOptions(),
28 | new DiagnosticListener("FakeDiagnosticListener")),
29 | new DiagnosticsLogger(
30 | new LoggerFactory(),
31 | new LoggingOptions(),
32 | new DiagnosticListener("FakeDiagnosticListener")),
33 | new NamedConnectionStringResolver(options),
34 | new RelationalTransactionFactory(new RelationalTransactionFactoryDependencies())))
35 | {
36 | }
37 |
38 | public void UseConnection(DbConnection connection) => _connection = connection;
39 |
40 | public override DbConnection DbConnection => _connection ?? base.DbConnection;
41 |
42 | public IReadOnlyList DbConnections => _dbConnections;
43 |
44 | protected override DbConnection CreateDbConnection()
45 | {
46 | var connection = new FakeDbConnection(ConnectionString);
47 |
48 | _dbConnections.Add(connection);
49 |
50 | return connection;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/FakeProvider/FakeRelationalDatabaseCreator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using Microsoft.EntityFrameworkCore.Storage;
8 |
9 | namespace Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider
10 | {
11 | public class FakeRelationalDatabaseCreator : IRelationalDatabaseCreator
12 | {
13 | public bool EnsureDeleted()
14 | {
15 | throw new NotImplementedException();
16 | }
17 |
18 | public Task EnsureDeletedAsync(CancellationToken cancellationToken = new CancellationToken())
19 | {
20 | throw new NotImplementedException();
21 | }
22 |
23 | public bool EnsureCreated()
24 | {
25 | throw new NotImplementedException();
26 | }
27 |
28 | public Task EnsureCreatedAsync(CancellationToken cancellationToken = new CancellationToken())
29 | {
30 | throw new NotImplementedException();
31 | }
32 |
33 | public bool Exists()
34 | {
35 | throw new NotImplementedException();
36 | }
37 |
38 | public Task ExistsAsync(CancellationToken cancellationToken = new CancellationToken())
39 | {
40 | throw new NotImplementedException();
41 | }
42 |
43 | public void Create()
44 | {
45 | throw new NotImplementedException();
46 | }
47 |
48 | public Task CreateAsync(CancellationToken cancellationToken = new CancellationToken())
49 | {
50 | throw new NotImplementedException();
51 | }
52 |
53 | public void Delete()
54 | {
55 | throw new NotImplementedException();
56 | }
57 |
58 | public Task DeleteAsync(CancellationToken cancellationToken = new CancellationToken())
59 | {
60 | throw new NotImplementedException();
61 | }
62 |
63 | public void CreateTables()
64 | {
65 | throw new NotImplementedException();
66 | }
67 |
68 | public Task CreateTablesAsync(CancellationToken cancellationToken = new CancellationToken())
69 | {
70 | throw new NotImplementedException();
71 | }
72 |
73 | public string GenerateCreateScript()
74 | {
75 | throw new NotImplementedException();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/RelationalTestHelpers.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider;
6 | using Microsoft.Extensions.DependencyInjection;
7 |
8 | namespace Microsoft.EntityFrameworkCore.TestUtilities
9 | {
10 | public class RelationalTestHelpers : TestHelpers
11 | {
12 | protected RelationalTestHelpers()
13 | {
14 | }
15 |
16 | public static RelationalTestHelpers Instance { get; } = new RelationalTestHelpers();
17 |
18 | public override IServiceCollection AddProviderServices(IServiceCollection services)
19 | => FakeRelationalOptionsExtension.AddEntityFrameworkRelationalDatabase(services);
20 |
21 | protected override void UseProviderOptions(DbContextOptionsBuilder optionsBuilder)
22 | {
23 | var extension = optionsBuilder.Options.FindExtension()
24 | ?? new FakeRelationalOptionsExtension();
25 |
26 | ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(
27 | extension.WithConnection(new FakeDbConnection("Database=Fake")));
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestModificationCommandBatchFactory.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Storage;
5 | using Microsoft.EntityFrameworkCore.Update;
6 |
7 | namespace Microsoft.EntityFrameworkCore.TestUtilities
8 | {
9 | public class TestModificationCommandBatchFactory : IModificationCommandBatchFactory
10 | {
11 | private readonly IRelationalCommandBuilderFactory _commandBuilderFactory;
12 | private readonly ISqlGenerationHelper _sqlGenerationHelper;
13 | private readonly IUpdateSqlGenerator _updateSqlGenerator;
14 | private readonly IRelationalValueBufferFactoryFactory _valueBufferFactoryFactory;
15 |
16 | public TestModificationCommandBatchFactory(
17 | IRelationalCommandBuilderFactory commandBuilderFactory,
18 | ISqlGenerationHelper sqlGenerationHelper,
19 | IUpdateSqlGenerator updateSqlGenerator,
20 | IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
21 | {
22 | _commandBuilderFactory = commandBuilderFactory;
23 | _sqlGenerationHelper = sqlGenerationHelper;
24 | _updateSqlGenerator = updateSqlGenerator;
25 | _valueBufferFactoryFactory = valueBufferFactoryFactory;
26 | }
27 |
28 | public int CreateCount { get; private set; }
29 |
30 | public virtual ModificationCommandBatch Create()
31 | {
32 | CreateCount++;
33 |
34 | return new SingularModificationCommandBatch(
35 | _commandBuilderFactory,
36 | _sqlGenerationHelper,
37 | _updateSqlGenerator,
38 | _valueBufferFactoryFactory);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestProviderCodeGenerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Design;
5 | using Microsoft.EntityFrameworkCore.Scaffolding;
6 |
7 | namespace Microsoft.EntityFrameworkCore.TestUtilities
8 | {
9 | public class TestProviderCodeGenerator : ProviderCodeGenerator
10 | {
11 | public TestProviderCodeGenerator(ProviderCodeGeneratorDependencies dependencies)
12 | : base(dependencies)
13 | {
14 | }
15 |
16 | public override MethodCallCodeFragment GenerateUseProvider(string connectionString)
17 | => new MethodCallCodeFragment("UseTestProvider", connectionString);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestQuerySqlGenerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Query.Expressions;
5 | using Microsoft.EntityFrameworkCore.Query.Sql;
6 |
7 | namespace Microsoft.EntityFrameworkCore.TestUtilities
8 | {
9 | public class TestQuerySqlGenerator : DefaultQuerySqlGenerator
10 | {
11 | public TestQuerySqlGenerator(
12 | QuerySqlGeneratorDependencies dependencies,
13 | SelectExpression selectExpression)
14 | : base(dependencies, selectExpression)
15 | {
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestQuerySqlGeneratorFactory.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Query.Expressions;
5 | using Microsoft.EntityFrameworkCore.Query.Sql;
6 |
7 | namespace Microsoft.EntityFrameworkCore.TestUtilities
8 | {
9 | public class TestQuerySqlGeneratorFactory : QuerySqlGeneratorFactoryBase
10 | {
11 | public TestQuerySqlGeneratorFactory(QuerySqlGeneratorDependencies dependencies)
12 | : base(dependencies)
13 | {
14 | }
15 |
16 | public override IQuerySqlGenerator CreateDefault(SelectExpression selectExpression)
17 | => new TestQuerySqlGenerator(Dependencies, selectExpression);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestRelationalCompositeMemberTranslator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
5 |
6 | namespace Microsoft.EntityFrameworkCore.TestUtilities
7 | {
8 | public class TestRelationalCompositeMemberTranslator : RelationalCompositeMemberTranslator
9 | {
10 | public TestRelationalCompositeMemberTranslator(RelationalCompositeMemberTranslatorDependencies dependencies)
11 | : base(dependencies)
12 | {
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestRelationalCompositeMethodCallTranslator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
5 |
6 | namespace Microsoft.EntityFrameworkCore.TestUtilities
7 | {
8 | public class TestRelationalCompositeMethodCallTranslator : RelationalCompositeMethodCallTranslator
9 | {
10 | public TestRelationalCompositeMethodCallTranslator(RelationalCompositeMethodCallTranslatorDependencies dependencies)
11 | : base(dependencies)
12 | {
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestRelationalConventionSetBuilder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Metadata.Conventions;
5 | using Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal;
6 | using Microsoft.EntityFrameworkCore.Storage;
7 |
8 | namespace Microsoft.EntityFrameworkCore.TestUtilities
9 | {
10 | public class TestRelationalConventionSetBuilder : RelationalConventionSetBuilder
11 | {
12 | public TestRelationalConventionSetBuilder(RelationalConventionSetBuilderDependencies dependencies)
13 | : base(dependencies)
14 | {
15 | }
16 |
17 | public static ConventionSet Build()
18 | => new TestRelationalConventionSetBuilder(
19 | new RelationalConventionSetBuilderDependencies(
20 | new TestRelationalTypeMappingSource(
21 | TestServiceFactory.Instance.Create(),
22 | TestServiceFactory.Instance.Create()),
23 | new FakeDiagnosticsLogger(),
24 | null,
25 | null,
26 | null))
27 | .AddConventions(
28 | TestServiceFactory.Instance.Create()
29 | .CreateConventionSet());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestRelationalMetadataExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 |
6 | namespace Microsoft.EntityFrameworkCore.TestUtilities
7 | {
8 | public static class TestRelationalMetadataExtensions
9 | {
10 | public static IRelationalPropertyAnnotations TestProvider(this IProperty property)
11 | => new RelationalPropertyAnnotations(property);
12 |
13 | public static IRelationalEntityTypeAnnotations TestProvider(this IEntityType entityType)
14 | => new RelationalEntityTypeAnnotations(entityType);
15 |
16 | public static IRelationalKeyAnnotations TestProvider(this IKey key)
17 | => new RelationalKeyAnnotations(key);
18 |
19 | public static IRelationalIndexAnnotations TestProvider(this IIndex index)
20 | => new RelationalIndexAnnotations(index);
21 |
22 | public static IRelationalForeignKeyAnnotations TestProvider(this IForeignKey foreignKey)
23 | => new RelationalForeignKeyAnnotations(foreignKey);
24 |
25 | public static IRelationalModelAnnotations TestProvider(this IModel model)
26 | => new RelationalModelAnnotations(model);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact.Tests/Utilities/TestRelationalMigrationSqlGenerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Migrations.Operations;
7 |
8 | namespace Microsoft.EntityFrameworkCore.TestUtilities
9 | {
10 | public class TestRelationalMigrationSqlGenerator : MigrationsSqlGenerator
11 | {
12 | public TestRelationalMigrationSqlGenerator(MigrationsSqlGeneratorDependencies dependencies)
13 | : base(dependencies)
14 | {
15 | }
16 |
17 | protected override void Generate(RenameTableOperation operation, IModel model, MigrationCommandListBuilder builder)
18 | {
19 | }
20 |
21 | protected override void Generate(DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder)
22 | {
23 | }
24 |
25 | protected override void Generate(RenameSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)
26 | {
27 | }
28 |
29 | protected override void Generate(RenameColumnOperation operation, IModel model, MigrationCommandListBuilder builder)
30 | {
31 | }
32 |
33 | protected override void Generate(EnsureSchemaOperation operation, IModel model, MigrationCommandListBuilder builder)
34 | {
35 | }
36 |
37 | protected override void Generate(RenameIndexOperation operation, IModel model, MigrationCommandListBuilder builder)
38 | {
39 | }
40 |
41 | protected override void Generate(AlterColumnOperation operation, IModel model, MigrationCommandListBuilder builder)
42 | {
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact35.FunctionalTests/NWforEF7.sqlce:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/test/EntityFramework.SqlServerCompact35.FunctionalTests/NWforEF7.sqlce
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact35.FunctionalTests/NorthwindEF735.sdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/test/EntityFramework.SqlServerCompact35.FunctionalTests/NorthwindEF735.sdf
--------------------------------------------------------------------------------
/test/EntityFramework.SqlServerCompact35.FunctionalTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EntityFramework.SqlServerCompact.Legacy.FunctionalTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EntityFramework.SqlServerCompact.Legacy.FunctionalTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("54867677-196e-4c26-832b-3846a937e649")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/tools/SSCERuntime_x64-ENU.msi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/tools/SSCERuntime_x64-ENU.msi
--------------------------------------------------------------------------------
/tools/SSCERuntime_x86-ENU.msi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErikEJ/EntityFramework.SqlServerCompact/4f83aa32c0d4077c064a1c5ec254e78c8fb33478/tools/SSCERuntime_x86-ENU.msi
--------------------------------------------------------------------------------