mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-08-15 18:44:57 +00:00
Support for the params keyword
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
SELECT [t].[Id]
|
||||
FROM [TestEntity] AS [t]
|
||||
WHERE [t].[Id] IN (1, 2, 3)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
SELECT [t].[Id]
|
||||
FROM [TestEntity] AS [t]
|
||||
WHERE [t].[Id] IN (1, 2, 3)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
SELECT [t].[Id]
|
||||
FROM [TestEntity] AS [t]
|
||||
WHERE [t].[Id] IN (1, 2, 3)
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EntityFrameworkCore.Projectables.FunctionalTests.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using VerifyXunit;
|
||||
using Xunit;
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.FunctionalTests
|
||||
{
|
||||
[UsesVerify]
|
||||
public class ComplexArgumentsTests
|
||||
{
|
||||
public class TestEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Projectable]
|
||||
public bool IsValid1(List<int> validIds) => validIds.Contains(Id);
|
||||
|
||||
[Projectable]
|
||||
public bool IsValid2(int[] validIds) => validIds.Contains(Id);
|
||||
|
||||
[Projectable]
|
||||
public bool IsValid3(params int[] validIds) => validIds.Contains(Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ListOfPrimitivesArguments()
|
||||
{
|
||||
using var dbContext = new SampleDbContext<TestEntity>();
|
||||
|
||||
var validList = new List<int>() { 1, 2, 3 };
|
||||
|
||||
var query = dbContext.Set<TestEntity>()
|
||||
.Where(x => x.IsValid1(validList));
|
||||
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ArrayOfPrimitivesArguments()
|
||||
{
|
||||
using var dbContext = new SampleDbContext<TestEntity>();
|
||||
|
||||
var validArray = new[] { 1, 2, 3 };
|
||||
|
||||
var query = dbContext.Set<TestEntity>()
|
||||
.Where(x => x.IsValid2(validArray));
|
||||
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public Task ParamsOfPrimitivesArguments()
|
||||
{
|
||||
using var dbContext = new SampleDbContext<TestEntity>();
|
||||
|
||||
var query = dbContext.Set<TestEntity>()
|
||||
.Where(x => x.IsValid3(1, 2, 3));
|
||||
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user