Skip to content

Commit a815faf

Browse files
authored
Merge pull request #11 from yv989c/develop
Reused parameter support
2 parents 4635414 + 9bb5403 commit a815faf

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

.github/workflows/ci-workflow.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: windows-latest
4040
steps:
4141
- name: Checkout
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v3
4343

4444
- name: Setup MSBuild
4545
uses: microsoft/[email protected]
@@ -65,7 +65,7 @@ jobs:
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
6666
6767
- name: Upload Artifacts
68-
uses: actions/upload-artifact@v2
68+
uses: actions/upload-artifact@v3
6969
with:
7070
name: nupkg
7171
path: ./src/QueryableValues.EF6.SqlServer/bin/Release/*.nupkg
@@ -75,7 +75,7 @@ jobs:
7575
runs-on: windows-latest
7676
steps:
7777
- name: Download Artifact
78-
uses: actions/download-artifact@v1
78+
uses: actions/download-artifact@v3
7979
with:
8080
name: nupkg
8181
- name: Push to GitHub Feed
@@ -88,7 +88,7 @@ jobs:
8888
runs-on: windows-latest
8989
steps:
9090
- name: Download Artifact
91-
uses: actions/download-artifact@v1
91+
uses: actions/download-artifact@v3
9292
with:
9393
name: nupkg
9494
- name: Push to GitHub Feed

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.1.0</VersionPrefix>
3+
<VersionPrefix>1.1.1</VersionPrefix>
44
</PropertyGroup>
55
</Project>

src/QueryableValues.EF6.SqlServer/QueryableValuesCommandInterceptor.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,14 @@ private static void TransformCommand(DbCommand command, DbCommandInterceptionCon
128128
_ => throw new NotImplementedException(),
129129
};
130130

131-
parameters.Add(valueParameterName, serializationFormat);
131+
#if NET452 || NET472
132+
if (!parameters.ContainsKey(valueParameterName))
133+
{
134+
parameters.Add(valueParameterName, serializationFormat);
135+
}
136+
#else
137+
parameters.TryAdd(valueParameterName, serializationFormat);
138+
#endif
132139

133140
#if NET452 || NET472
134141
sb.Append(originalCommandText.Substring(lastStartIndex, match2.Index - lastStartIndex));

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ IEnumerable<int> getSequenceInt32()
131131
}
132132
}
133133

134-
135134
[Theory]
136135
[MemberData(nameof(Data))]
137136
public async Task Complex3(bool useCompat120, bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
@@ -232,6 +231,57 @@ IEnumerable<int> getSequenceInt32()
232231
}
233232
}
234233

234+
[Theory]
235+
[MemberData(nameof(Data))]
236+
public async Task Complex5(bool useCompat120, bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)
237+
{
238+
using (var db = DbUtil.CreateDbContext(useDatabaseFirst, useDatabaseNullSemantics, useCompat120: useCompat120))
239+
{
240+
var sequenceStringUnicode = GetSequence(getSequenceString(), withCount);
241+
var qvStringUnicode = db.AsQueryableValues(sequenceStringUnicode, isUnicode: true);
242+
243+
var sequenceInt32 = GetSequence(getSequenceInt32(), withCount);
244+
var qvInt32 = db.AsQueryableValues(sequenceInt32);
245+
246+
var query =
247+
from e in db.TestData
248+
where qvStringUnicode.Contains(e.StringUnicodeValue) || qvInt32.Contains(e.Int32Value)
249+
select e;
250+
251+
var result = await query
252+
.GroupBy(x => new { x.Int32Value })
253+
.OrderByDescending(g => g.Key.Int32Value)
254+
.Select(g => g.FirstOrDefault().Id)
255+
.OrderBy(i => i)
256+
.ToListAsync();
257+
258+
var expected = GetExpected(isEmpty, 1, 2, 4);
259+
260+
Assert.Equal(expected, result);
261+
}
262+
263+
IEnumerable<string> getSequenceString()
264+
{
265+
if (isEmpty)
266+
{
267+
yield break;
268+
}
269+
270+
yield return "你好!";
271+
yield return "👋";
272+
}
273+
274+
IEnumerable<int> getSequenceInt32()
275+
{
276+
if (isEmpty)
277+
{
278+
yield break;
279+
}
280+
281+
yield return 123;
282+
}
283+
}
284+
235285
[Theory]
236286
[MemberData(nameof(Data))]
237287
public void DocsExamples<T>(bool useCompat120, bool useDatabaseFirst, bool useDatabaseNullSemantics, bool withCount, bool isEmpty)

0 commit comments

Comments
 (0)