Skip to content

Commit 4635414

Browse files
authored
Merge pull request #8 from yv989c/develop
JSON Support
2 parents 9463949 + 5632bdb commit 4635414

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1495
-272
lines changed

.github/workflows/ci-workflow.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ jobs:
4343

4444
- name: Setup MSBuild
4545
uses: microsoft/[email protected]
46-
#- name: Setup VSTest
47-
# uses: darenm/Setup-VSTest@v1
4846

4947
- name: Restore
5048
run: dotnet restore BlazarTech.QueryableValues.EF6.sln
@@ -59,17 +57,12 @@ jobs:
5957

6058
# Tests
6159
- name: Build
60+
if: github.event_name == 'pull_request'
6261
run: msbuild BlazarTech.QueryableValues.EF6.sln -property:Configuration=Release -property:RestorePackages=false
6362
- name: Tests
63+
if: github.event_name == 'pull_request'
6464
run: |
6565
& "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/Extensions/TestPlatform/vstest.console.exe" ./tests/QueryableValues.EF6.SqlServer.Tests.EF*/bin/Release/**/BlazarTech.QueryableValues.EF6.SqlServer.Tests.EF*.dll
66-
#uses: microsoft/[email protected]
67-
#with:
68-
# testAssembly: BlazarTech.QueryableValues.EF6.SqlServer.Tests.EF*.dll
69-
# searchFolder: ./tests/QueryableValues.EF6.SqlServer.Tests.EF*/bin/Release/**/
70-
# runInParallel: false
71-
# vstestLocationMethod: location
72-
# vstestLocation: 'C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/Extensions/TestPlatform/vstest.console.exe'
7366
7467
- name: Upload Artifacts
7568
uses: actions/upload-artifact@v2
@@ -78,7 +71,7 @@ jobs:
7871
path: ./src/QueryableValues.EF6.SqlServer/bin/Release/*.nupkg
7972
prerelease:
8073
needs: build
81-
if: github.ref == 'refs/heads/develop'
74+
if: github.event_name != 'release'
8275
runs-on: windows-latest
8376
steps:
8477
- name: Download Artifact

BlazarTech.QueryableValues.EF6.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QueryableValues.EF6.SqlServ
2323
EndProject
2424
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QueryableValues.EF6.SqlServer.Tests.EF64.DotNetCore", "tests\QueryableValues.EF6.SqlServer.Tests.EF64.DotNetCore\QueryableValues.EF6.SqlServer.Tests.EF64.DotNetCore.csproj", "{A0D2A4DB-C029-45A3-B318-5BBC5DEC1CED}"
2525
EndProject
26+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QueryableValues.EF6.SqlServer.Benchmarks", "benchmarks\QueryableValues.EF6.SqlServer.Benchmarks\QueryableValues.EF6.SqlServer.Benchmarks.csproj", "{C8BB5DB3-BA90-47DF-B603-A8A781CA32B0}"
27+
EndProject
2628
Global
2729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2830
Debug|Any CPU = Debug|Any CPU
@@ -57,6 +59,10 @@ Global
5759
{A0D2A4DB-C029-45A3-B318-5BBC5DEC1CED}.Debug|Any CPU.Build.0 = Debug|Any CPU
5860
{A0D2A4DB-C029-45A3-B318-5BBC5DEC1CED}.Release|Any CPU.ActiveCfg = Release|Any CPU
5961
{A0D2A4DB-C029-45A3-B318-5BBC5DEC1CED}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{C8BB5DB3-BA90-47DF-B603-A8A781CA32B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{C8BB5DB3-BA90-47DF-B603-A8A781CA32B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{C8BB5DB3-BA90-47DF-B603-A8A781CA32B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{C8BB5DB3-BA90-47DF-B603-A8A781CA32B0}.Release|Any CPU.Build.0 = Release|Any CPU
6066
EndGlobalSection
6167
GlobalSection(SolutionProperties) = preSolution
6268
HideSolutionNode = FALSE

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ using BlazarTech.QueryableValues;
4343

4444
> 💡 If you access your [DbContext] via an interface, you can also make the `AsQueryableValues` extension methods available on it by inheriting from the `IQueryableValuesEnabledDbContext` interface.
4545
46+
> 💡 You can configure the behavior of QueryableValues `EF6 Edition` by using the `QueryableValuesConfigurator` class.
47+
4648
Below are a few examples composing a query using the values provided by an [IEnumerable<T>].
4749

4850
### Examples

Version.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>1.0.1</VersionPrefix>
3+
<VersionPrefix>1.1.0</VersionPrefix>
44
</PropertyGroup>
55
</Project>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace BlazarTech.QueryableValues.EF6.SqlServer.Benchmarks;
5+
6+
public sealed class DbContextFixture : IDisposable
7+
{
8+
public TestDbContext Db { get; }
9+
10+
public DbContextFixture()
11+
{
12+
Db = TestDbContext.Create();
13+
}
14+
15+
public void Dispose()
16+
{
17+
Db.Dispose();
18+
GC.SuppressFinalize(this);
19+
}
20+
21+
public async Task InitializeAsync()
22+
{
23+
var sw = System.Diagnostics.Stopwatch.StartNew();
24+
25+
Console.WriteLine("Creating DB...");
26+
Db.Database.Delete();
27+
Db.Database.Create();
28+
Console.WriteLine($"DB Created ({sw.ElapsedMilliseconds}ms)");
29+
30+
sw.Restart();
31+
32+
Console.WriteLine("Seeding DB...");
33+
await Seed(Db);
34+
Console.WriteLine($"DB Seeded ({sw.ElapsedMilliseconds}ms)");
35+
}
36+
37+
private static async Task Seed(TestDbContext testDbContext)
38+
{
39+
var dateTimeOffset = new DateTimeOffset(1999, 12, 31, 23, 59, 59, 0, TimeSpan.FromHours(5));
40+
41+
var data = new[]
42+
{
43+
// 1
44+
new TestDataEntity
45+
{
46+
BoolValue = false,
47+
ByteValue = byte.MinValue,
48+
Int16Value = short.MinValue,
49+
Int32Value = int.MinValue,
50+
Int64Value = long.MinValue,
51+
DecimalValue = -1234567.890123M,
52+
SingleValue = -1234567.890123F,
53+
DoubleValue = -1234567.890123D,
54+
//CharValue = 'A',
55+
//CharUnicodeValue = '\u2603',
56+
StringValue = "Hola!",
57+
StringUnicodeValue = "👋",
58+
DateTimeValue = DateTime.MinValue,
59+
DateTimeOffsetValue = DateTimeOffset.MinValue,
60+
GuidValue = Guid.Empty
61+
},
62+
// 2
63+
new TestDataEntity
64+
{
65+
Int32Value = 0,
66+
Int64Value = 0,
67+
DecimalValue = 0,
68+
SingleValue = 12345.67F,
69+
DoubleValue = 0,
70+
StringValue = "Hallo!",
71+
StringUnicodeValue = "你好!",
72+
DateTimeValue = dateTimeOffset.DateTime,
73+
DateTimeOffsetValue = dateTimeOffset,
74+
GuidValue = new Guid("df2c9bfe-9d83-4331-97ce-2876d5dc6576")
75+
},
76+
// 3
77+
new TestDataEntity
78+
{
79+
BoolValue = true,
80+
ByteValue = byte.MaxValue,
81+
Int16Value = short.MaxValue,
82+
Int32Value = int.MaxValue,
83+
Int64Value = long.MaxValue,
84+
DecimalValue = 1234567.890123M,
85+
SingleValue = 1234567.890123F,
86+
DoubleValue = 1234567.890123D,
87+
//CharValue = 'c',
88+
//CharUnicodeValue = '\u2622',
89+
StringValue = "Hi!",
90+
StringUnicodeValue = "أهلا",
91+
DateTimeValue = DateTime.MaxValue,
92+
DateTimeOffsetValue = DateTimeOffset.MaxValue,
93+
GuidValue = new Guid("f6379213-750f-42df-91b9-73756f28c4b6")
94+
},
95+
// 4
96+
new TestDataEntity
97+
{
98+
BoolValue = true,
99+
ByteValue = 123,
100+
Int16Value = 123,
101+
Int32Value = 123,
102+
Int64Value = 123,
103+
DecimalValue = 123M,
104+
SingleValue = 123F,
105+
DoubleValue = 123D,
106+
//CharValue = 'c',
107+
//CharUnicodeValue = '\u2622',
108+
StringValue = "Olá!",
109+
StringUnicodeValue = "أهلا",
110+
DateTimeValue = new DateTime(2000, 1, 1),
111+
DateTimeOffsetValue = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero),
112+
GuidValue = new Guid("4ec4f690-a13c-4669-b622-351b3e568e68")
113+
}
114+
};
115+
116+
testDbContext.TestData.AddRange(data);
117+
118+
await testDbContext.SaveChangesAsync();
119+
}
120+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.IO;
2+
3+
namespace BlazarTech.QueryableValues.EF6.SqlServer.Benchmarks;
4+
5+
internal static class DbUtil
6+
{
7+
public static string GetConnectionString(bool useDatabaseFirst, string databaseNameSuffix = "Tests")
8+
{
9+
var databaseName = $"QueryableValues.EF6.{databaseNameSuffix}";
10+
var databaseFilePath = Path.Combine(Path.GetTempPath(), $"{databaseName}.mdf");
11+
var connectionString = @$"Server=(localdb)\MSSQLLocalDB;Integrated Security=true;Connection Timeout=190;Database={databaseName};AttachDbFileName={databaseFilePath}";
12+
13+
if (useDatabaseFirst)
14+
{
15+
return $"metadata=res://*/DatabaseFirst.TestModels.csdl|res://*/DatabaseFirst.TestModels.ssdl|res://*/DatabaseFirst.TestModels.msl;provider=System.Data.SqlClient;provider connection string=\"{connectionString}\"";
16+
}
17+
else
18+
{
19+
return connectionString;
20+
}
21+
}
22+
23+
public static string GetConnectionStringMasterDb()
24+
{
25+
return @"Server=(localdb)\MSSQLLocalDB;Integrated Security=true;Connection Timeout=190;Database=master";
26+
}
27+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using BenchmarkDotNet.Running;
2+
3+
namespace BlazarTech.QueryableValues.EF6.SqlServer.Benchmarks;
4+
5+
internal class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
BenchmarkRunner.Run<SqlServerBenchmarks>();
10+
}
11+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<RootNamespace>BlazarTech.QueryableValues.EF6.SqlServer.Benchmarks</RootNamespace>
5+
<OutputType>Exe</OutputType>
6+
<TargetFramework>net6.0</TargetFramework>
7+
<!--<TargetFrameworks>net472;net6.0</TargetFrameworks>-->
8+
<!--<ImplicitUsings>enable</ImplicitUsings>-->
9+
<!--<Nullable>enable</Nullable>-->
10+
<!--<LangVersion>10</LangVersion>-->
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
15+
<PackageReference Include="EntityFramework" Version="6.4.4" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\..\src\QueryableValues.EF6.SqlServer\QueryableValues.EF6.SqlServer.csproj" />
20+
</ItemGroup>
21+
22+
</Project>

0 commit comments

Comments
 (0)