Skip to content

Commit db68837

Browse files
committed
Added project to check that compile time error CS0121 is supressed
1 parent 5f4292d commit db68837

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

TestFromSqlRaw/DbContext1.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2020 Jon P Smith, GitHub: JonPSmith, web: http://www.thereformedprogrammer.net/
2+
// Licensed under MIT license. See License.txt in the project root for license information.
3+
4+
using Microsoft.EntityFrameworkCore;
5+
6+
namespace TestFromSqlRaw
7+
{
8+
public class MyDbContext : DbContext
9+
{
10+
public MyDbContext(DbContextOptions<MyDbContext> options)
11+
: base(options) { }
12+
13+
public DbSet<MyEntity> MyEntities { get; set; }
14+
}
15+
}

TestFromSqlRaw/MyEntity.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+

2+
namespace TestFromSqlRaw
3+
{
4+
public class MyEntity
5+
{
6+
public int Id { get; set; }
7+
public string Name { get; set; }
8+
}
9+
}

TestFromSqlRaw/Program.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using TestSupport.EfHelpers;
3+
4+
namespace TestFromSqlRaw
5+
{
6+
public class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
var options = SqliteInMemory.CreateOptions<MyDbContext>();
11+
var context = new MyDbContext(options);
12+
13+
//This shows that making the Microsoft.EntityFrameworkCore.Cosmos NuGet package private
14+
//to the TestSupport project removes the compile-time error "The call is ambiguous..." - SEE BELOW
15+
//
16+
//Code CS0121: The call is ambiguous between the following methods or properties:
17+
//'Microsoft.EntityFrameworkCore.RelationalQueryableExtensions.FromSqlRaw<TEntity>(Microsoft.EntityFrameworkCore.DbSet<TEntity>, string, params object[])' and
18+
//'Microsoft.EntityFrameworkCore.CosmosQueryableExtensions.FromSqlRaw<TEntity>(Microsoft.EntityFrameworkCore.DbSet<TEntity>, string, params object[])'
19+
20+
context.MyEntities.FromSqlRaw("Select * FROM MyEntities");
21+
}
22+
}
23+
}
24+
25+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\TestSupport\TestSupport.csproj" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)