mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-08-15 18:44:57 +00:00
Find overriding implementations for virtual methods
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
SELECT 1 + 1
|
||||
FROM [Concrete] AS [c]
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
SELECT 1 + 1
|
||||
FROM [Concrete] AS [c]
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
SELECT 1 + 1
|
||||
FROM [Concrete] AS [c]
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
SELECT 1 + 1
|
||||
FROM [Concrete] AS [c]
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EntityFrameworkCore.Projectables.FunctionalTests.Helpers;
|
||||
using EntityFrameworkCore.Projectables.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ScenarioTests;
|
||||
using VerifyXunit;
|
||||
using Xunit;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EntityFrameworkCore.Projectables.FunctionalTests
|
||||
{
|
||||
|
||||
[UsesVerify]
|
||||
public class InheritedModelTests
|
||||
{
|
||||
public abstract class Base
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Projectable]
|
||||
public int ComputedProperty => SampleProperty + 1;
|
||||
|
||||
public virtual int SampleProperty => 0;
|
||||
|
||||
[Projectable]
|
||||
public int ComputedMethod() => SampleMethod() + 1;
|
||||
|
||||
public virtual int SampleMethod() => 0;
|
||||
}
|
||||
|
||||
public class Concrete : Base
|
||||
{
|
||||
[Projectable]
|
||||
public override int SampleProperty => 1;
|
||||
|
||||
[Projectable]
|
||||
public override int SampleMethod() => 1;
|
||||
}
|
||||
|
||||
public class MoreConcrete : Concrete
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ProjectOverOverriddenPropertyImplementation()
|
||||
{
|
||||
using var dbContext = new SampleDbContext<Concrete>();
|
||||
|
||||
var query = dbContext.Set<Concrete>()
|
||||
.Select(x => x.ComputedProperty);
|
||||
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ProjectOverInheritedPropertyImplementation()
|
||||
{
|
||||
using var dbContext = new SampleDbContext<Concrete>();
|
||||
|
||||
var query = dbContext.Set<Concrete>()
|
||||
.Select(x => x.ComputedProperty);
|
||||
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ProjectOverOverriddenMethodImplementation()
|
||||
{
|
||||
using var dbContext = new SampleDbContext<Concrete>();
|
||||
|
||||
var query = dbContext.Set<Concrete>()
|
||||
.Select(x => x.ComputedMethod());
|
||||
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ProjectOverInheritedMethodImplementation()
|
||||
{
|
||||
using var dbContext = new SampleDbContext<Concrete>();
|
||||
|
||||
var query = dbContext.Set<Concrete>()
|
||||
.Select(x => x.ComputedMethod());
|
||||
|
||||
return Verifier.Verify(query.ToQueryString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user