Skip to content

Commit ff940a3

Browse files
authored
Merge pull request #4 from yv989c/develop
Ready for the world!
2 parents b139406 + 9037b11 commit ff940a3

File tree

13 files changed

+147
-183
lines changed

13 files changed

+147
-183
lines changed

.github/workflows/ci-workflow.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ jobs:
6060
# Tests
6161
- name: Build
6262
run: msbuild BlazarTech.QueryableValues.EF6.sln -property:Configuration=Release -property:RestorePackages=false
63-
#- name: Tests
64-
# run: vstest.console.exe tests/QueryableValues.EF6.SqlServer.Tests.EF*/bin/Release/**/BlazarTech.QueryableValues.EF6.SqlServer.Tests.EF*.dll
6563
- name: Tests
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
64+
run: |
65+
& "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'
7173

7274
- name: Upload Artifacts
7375
uses: actions/upload-artifact@v2

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src="/docs/images/icon.png" alt="Logo" style="width: 80px;">
33
</p>
44

5-
# QueryableValues for EF6
5+
# QueryableValues `EF6 Edition`
66

77
[![MIT License](https://badgen.net/badge/license/MIT/blue)](https://github.com/yv989c/BlazarTech.QueryableValues.EF6/blob/main/LICENSE.md)
88
[![GitHub Stars](https://badgen.net/github/stars/yv989c/BlazarTech.QueryableValues.EF6?icon=github)][Repository]
@@ -16,7 +16,7 @@ For a detailed explanation of the problem solved by QueryableValues, please cont
1616

1717
> 💡 This is a streamlined version of the original [QueryableValues][QueryableValuesEFCoreRepository] for Entity Framework Core, which I have adapted to provide some of its features on [Entity Framework 6].
1818
19-
> 💡 Are you on Entity Framework Core? Use [the original version][QueryableValuesEFCoreRepository] of QueryableValues instead.
19+
> 💡 Using Entity Framework Core? Then [the original version][QueryableValuesEFCoreRepository] of QueryableValues is what you need.
2020
2121
## When Should You Use It?
2222
The `AsQueryableValues` extension method is intended for queries that are dependent upon a *non-constant* sequence of external values. In such cases, the underlying SQL query will be efficient on subsequent executions.
@@ -31,7 +31,7 @@ Your ⭐ on [this repository][Repository] also helps! Thanks! 🖖🙂
3131
# Getting Started
3232

3333
## Installation
34-
QueryableValues for EF6 is distributed as a [NuGet Package]. You can install it using the command below in your NuGet Package Manager Console window in Visual Studio:
34+
QueryableValues `EF6 Edition` is distributed as a [NuGet Package]. You can install it using the command below in your NuGet Package Manager Console window in Visual Studio:
3535

3636
`Install-Package BlazarTech.QueryableValues.EF6.SqlServer`
3737

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.0-rc.2</VersionPrefix>
3+
<VersionPrefix>1.0.0</VersionPrefix>
44
</PropertyGroup>
55
</Project>

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# QueryableValues for EF6
1+
# QueryableValues `EF6 Edition`
22

33
[![MIT License](https://badgen.net/badge/license/MIT/blue)](https://github.com/yv989c/BlazarTech.QueryableValues.EF6/blob/main/LICENSE.md)
44
[![GitHub Stars](https://badgen.net/github/stars/yv989c/BlazarTech.QueryableValues.EF6?icon=github)][Repository]
@@ -12,7 +12,7 @@ For a detailed explanation of the problem solved by QueryableValues, please cont
1212

1313
> 💡 This is a streamlined version of the original [QueryableValues][QueryableValuesEFCoreRepository] for Entity Framework Core, which I have adapted to provide some of its features on [Entity Framework 6].
1414
15-
> 💡 Are you on Entity Framework Core? Use [the original version][QueryableValuesEFCoreRepository] of QueryableValues instead.
15+
> 💡 Using Entity Framework Core? Then [the original version][QueryableValuesEFCoreRepository] of QueryableValues is what you need.
1616
1717
## When Should You Use It?
1818
The `AsQueryableValues` extension method is intended for queries that are dependent upon a *non-constant* sequence of external values. In such cases, the underlying SQL query will be efficient on subsequent executions.
@@ -27,7 +27,7 @@ Your ⭐ on [this repository][Repository] also helps! Thanks! 🖖🙂
2727
# Getting Started
2828

2929
## Installation
30-
QueryableValues for EF6 is distributed as a [NuGet Package]. You can install it using the command below in your NuGet Package Manager Console window in Visual Studio:
30+
QueryableValues `EF6 Edition` is distributed as a [NuGet Package]. You can install it using the command below in your NuGet Package Manager Console window in Visual Studio:
3131

3232
`Install-Package BlazarTech.QueryableValues.EF6.SqlServer`
3333

tests/QueryableValues.EF6.SqlServer.Tests.EF60/CodeFirst/TestDbContext.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ public TestDbContext(string connectionString) : base(connectionString)
1111
Database.SetInitializer<TestDbContext>(null);
1212
}
1313

14-
public static TestDbContext Create()
14+
public static TestDbContext Create(bool useDatabaseNullSemantics = false)
1515
{
16-
return new TestDbContext(DbUtil.GetConnectionString(false));
16+
return new TestDbContext(DbUtil.GetConnectionString(false))
17+
{
18+
Configuration =
19+
{
20+
UseDatabaseNullSemantics = useDatabaseNullSemantics
21+
}
22+
};
1723
}
1824

1925
protected override void OnModelCreating(DbModelBuilder modelBuilder)

tests/QueryableValues.EF6.SqlServer.Tests.EF60/DatabaseFirst/TestDbContext.Custom.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ public TestDbContext(string connectionString) : base(connectionString)
66
{
77
}
88

9-
public static TestDbContext Create()
9+
public static TestDbContext Create(bool useDatabaseNullSemantics = false)
1010
{
11-
return new TestDbContext(DbUtil.GetConnectionString(true));
11+
return new TestDbContext(DbUtil.GetConnectionString(true))
12+
{
13+
Configuration =
14+
{
15+
UseDatabaseNullSemantics = useDatabaseNullSemantics
16+
}
17+
};
1218
}
1319
}
1420
}

tests/QueryableValues.EF6.SqlServer.Tests.EF60/DbUtil.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,14 @@ public static string GetConnectionString(bool useDatabaseFirst)
1818
return connectionString;
1919
}
2020
}
21+
22+
public static ITestDbContextWithSauce CreateDbContext(bool useDatabaseFirst, bool useDatabaseNullSemantics)
23+
{
24+
var dbContext = useDatabaseFirst ?
25+
(ITestDbContextWithSauce)DatabaseFirst.TestDbContext.Create(useDatabaseNullSemantics) :
26+
CodeFirst.TestDbContext.Create(useDatabaseNullSemantics);
27+
28+
return dbContext;
29+
}
2130
}
2231
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Data.Entity;
1+
using System;
2+
using System.Data.Entity;
23

34
namespace BlazarTech.QueryableValues.EF6.SqlServer.Tests
45
{
@@ -7,7 +8,7 @@ public interface ITestDbContext
78
DbSet<DatabaseFirst.TestDataEntity> TestData { get; set; }
89
}
910

10-
public interface ITestDbContextWithSauce : ITestDbContext, IQueryableValuesEnabledDbContext
11+
public interface ITestDbContextWithSauce : ITestDbContext, IQueryableValuesEnabledDbContext, IDisposable
1112
{
1213
}
1314
}

tests/QueryableValues.EF6.SqlServer.Tests.EF60/Queries/ComplexTests.cs

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,10 @@ public static IEnumerable<object[]> Data
1818
{
1919
get
2020
{
21-
var options = new (bool WithCount, bool IsEmpty)[]
21+
foreach (var option in TestUtil.GetTestDataOptions())
2222
{
23-
(false, false),
24-
(false, true),
25-
(true, false),
26-
(true, true)
27-
};
28-
29-
#if NET5_0_OR_GREATER
30-
foreach (var option in options)
31-
{
32-
yield return new object[] { CodeFirst.TestDbContext.Create(), option.WithCount, option.IsEmpty };
33-
}
34-
#else
35-
foreach (var option in options)
36-
{
37-
yield return new object[] { CodeFirst.TestDbContext.Create(), option.WithCount, option.IsEmpty };
23+
yield return new object[] { option.UseDatabaseFirst, option.UseDatabaseNullSemantics, option.WithCount, option.IsEmpty };
3824
}
39-
40-
foreach (var option in options)
41-
{
42-
yield return new object[] { DatabaseFirst.TestDbContext.Create(), option.WithCount, option.IsEmpty };
43-
}
44-
#endif
4525
}
4626
}
4727

@@ -57,10 +37,9 @@ private static int[] GetExpected(bool isEmpty, params int[] expected)
5737

5838
[Theory]
5939
[MemberData(nameof(Data))]
60-
public async Task Complex1<T>(T db, bool withCount, bool isEmpty)
61-
where T : DbContext, ITestDbContext
40+
public async Task Complex1(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
6241
{
63-
using (db)
42+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
6443
{
6544
var sequence = GetSequence(getSequence(), withCount);
6645

@@ -99,10 +78,9 @@ IEnumerable<short> getSequenceInt16()
9978

10079
[Theory]
10180
[MemberData(nameof(Data))]
102-
public async Task Complex2<T>(T db, bool withCount, bool isEmpty)
103-
where T : DbContext, ITestDbContext
81+
public async Task Complex2(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
10482
{
105-
using (db)
83+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
10684
{
10785
var sequence = GetSequence(getSequence(), withCount);
10886

@@ -156,10 +134,9 @@ IEnumerable<int> getSequenceInt32()
156134

157135
[Theory]
158136
[MemberData(nameof(Data))]
159-
public async Task Complex3<T>(T db, bool withCount, bool isEmpty)
160-
where T : DbContext, ITestDbContext
137+
public async Task Complex3(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
161138
{
162-
using (db)
139+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
163140
{
164141
var sequenceStringUnicode = GetSequence(getSequenceString(), withCount);
165142
var qvStringUnicode = db.AsQueryableValues(sequenceStringUnicode, isUnicode: true);
@@ -203,10 +180,9 @@ IEnumerable<int> getSequenceInt32()
203180

204181
[Theory]
205182
[MemberData(nameof(Data))]
206-
public async Task Complex4<T>(T db, bool withCount, bool isEmpty)
207-
where T : DbContext, ITestDbContext
183+
public async Task Complex4(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
208184
{
209-
using (db)
185+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
210186
{
211187
var sequenceStringUnicode = GetSequence(getSequenceString(), withCount);
212188
var qvStringUnicode = db.AsQueryableValues(sequenceStringUnicode, isUnicode: true);
@@ -258,11 +234,12 @@ IEnumerable<int> getSequenceInt32()
258234

259235
[Theory]
260236
[MemberData(nameof(Data))]
261-
public void DocsExamples<T>(T dbContext, bool withCount, bool isEmpty)
262-
where T : DbContext, ITestDbContext
237+
public void DocsExamples<T>(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
263238
{
264239
IEnumerable<int> values = isEmpty ? Array.Empty<int>() : GetSequence(Enumerable.Range(1, 4), withCount);
265240

241+
using var dbContext = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics);
242+
266243
{
267244
var qvQuery = dbContext.AsQueryableValues(values);
268245

tests/QueryableValues.EF6.SqlServer.Tests.EF60/Queries/ContainsTests.cs

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,10 @@ public static IEnumerable<object[]> Data
1818
{
1919
get
2020
{
21-
var options = new (bool WithCount, bool IsEmpty)[]
21+
foreach (var option in TestUtil.GetTestDataOptions())
2222
{
23-
(false, false),
24-
(false, true),
25-
(true, false),
26-
(true, true)
27-
};
28-
29-
#if NET5_0_OR_GREATER
30-
foreach (var option in options)
31-
{
32-
yield return new object[] { CodeFirst.TestDbContext.Create(), option.WithCount, option.IsEmpty };
33-
}
34-
#else
35-
foreach (var option in options)
36-
{
37-
yield return new object[] { CodeFirst.TestDbContext.Create(), option.WithCount, option.IsEmpty };
38-
}
39-
40-
foreach (var option in options)
41-
{
42-
yield return new object[] { DatabaseFirst.TestDbContext.Create(), option.WithCount, option.IsEmpty };
23+
yield return new object[] { option.UseDatabaseFirst, option.UseDatabaseNullSemantics, option.WithCount, option.IsEmpty };
4324
}
44-
#endif
4525
}
4626
}
4727

@@ -57,10 +37,9 @@ private static int[] GetExpected(bool isEmpty, params int[] expected)
5737

5838
[Theory]
5939
[MemberData(nameof(Data))]
60-
public async Task Byte<T>(T db, bool withCount, bool isEmpty)
61-
where T : DbContext, ITestDbContext
40+
public async Task Byte(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
6241
{
63-
using (db)
42+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
6443
{
6544
var sequence = GetSequence(getSequence(), withCount);
6645
var qv = db.AsQueryableValues(sequence);
@@ -90,10 +69,9 @@ IEnumerable<byte> getSequence()
9069

9170
[Theory]
9271
[MemberData(nameof(Data))]
93-
public async Task Int16<T>(T db, bool withCount, bool isEmpty)
94-
where T : DbContext, ITestDbContext
72+
public async Task Int16(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
9573
{
96-
using (db)
74+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
9775
{
9876
var sequence = GetSequence(getSequence(), withCount);
9977
var qv = db.AsQueryableValues(sequence);
@@ -122,10 +100,9 @@ IEnumerable<short> getSequence()
122100

123101
[Theory]
124102
[MemberData(nameof(Data))]
125-
public async Task Int32<T>(T db, bool withCount, bool isEmpty)
126-
where T : DbContext, ITestDbContext
103+
public async Task Int32(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
127104
{
128-
using (db)
105+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
129106
{
130107
var sequence = GetSequence(getSequence(), withCount);
131108
var qv = db.AsQueryableValues(sequence);
@@ -156,10 +133,9 @@ IEnumerable<int> getSequence()
156133

157134
[Theory]
158135
[MemberData(nameof(Data))]
159-
public async Task Int64<T>(T db, bool withCount, bool isEmpty)
160-
where T : DbContext, ITestDbContext
136+
public async Task Int64(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
161137
{
162-
using (db)
138+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
163139
{
164140
var sequence = GetSequence(getSequence(), withCount);
165141
var qv = db.AsQueryableValues(sequence);
@@ -189,10 +165,9 @@ IEnumerable<long> getSequence()
189165

190166
[Theory]
191167
[MemberData(nameof(Data))]
192-
public async Task String<T>(T db, bool withCount, bool isEmpty)
193-
where T : DbContext, ITestDbContext
168+
public async Task String(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
194169
{
195-
using (db)
170+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
196171
{
197172
var sequence = GetSequence(getSequence(), withCount);
198173
var qv = db.AsQueryableValues(sequence, false);
@@ -222,10 +197,9 @@ IEnumerable<string> getSequence()
222197

223198
[Theory]
224199
[MemberData(nameof(Data))]
225-
public async Task StringUnicode<T>(T db, bool withCount, bool isEmpty)
226-
where T : DbContext, ITestDbContext
200+
public async Task StringUnicode(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
227201
{
228-
using (db)
202+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
229203
{
230204
var sequence = GetSequence(getSequence(), withCount);
231205
var qv = db.AsQueryableValues(sequence, true);
@@ -255,10 +229,9 @@ IEnumerable<string> getSequence()
255229

256230
[Theory]
257231
[MemberData(nameof(Data))]
258-
public async Task Guid<T>(T db, bool withCount, bool isEmpty)
259-
where T : DbContext, ITestDbContext
232+
public async Task Guid(bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
260233
{
261-
using (db)
234+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics))
262235
{
263236
var sequence = GetSequence(getSequence(), withCount);
264237
var qv = db.AsQueryableValues(sequence);

0 commit comments

Comments
 (0)