Temporary add test to replicate AccessViolationException in x64 ACE provider.
parent
11d56f868c
commit
130617fd75
@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Data.Jet;
|
||||
using System.Data.Odbc;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JetProviderExceptionTests
|
||||
{
|
||||
public class IceCreamTest
|
||||
{
|
||||
public class IceCream
|
||||
{
|
||||
public int IceCreamId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Brand { get; set; }
|
||||
public DateTime? BestServedBefore { get; set; }
|
||||
}
|
||||
|
||||
public class Context : DbContext
|
||||
{
|
||||
public DbSet<IceCream> IceCreams { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder
|
||||
// .UseJet("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=JetProviderExceptionTests.accdb")
|
||||
.UseJet(
|
||||
JetConnection.GetConnectionString("JetProviderExceptionTests.accdb", OdbcFactory.Instance),
|
||||
OdbcFactory.Instance)
|
||||
.UseLoggerFactory(
|
||||
LoggerFactory.Create(
|
||||
b => b
|
||||
.AddConsole()
|
||||
.AddFilter(level => level >= LogLevel.Information)))
|
||||
.EnableSensitiveDataLogging()
|
||||
.EnableDetailedErrors();
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
|
||||
modelBuilder.Entity<IceCream>()
|
||||
.HasData(
|
||||
new IceCream {IceCreamId = 1, Name = "Vanilla", Brand = "Ben & Jerry", BestServedBefore = today.AddDays(180)},
|
||||
new IceCream {IceCreamId = 2, Name = "Chocolate", Brand = "Baskin-Robbins", BestServedBefore = today.AddDays(210)},
|
||||
new IceCream {IceCreamId = 3, Name = "Strawberry", Brand = "Dairy Queen", BestServedBefore = today.AddDays(90)},
|
||||
new IceCream {IceCreamId = 4, Name = "Matcha", Brand = "Kikyouya", BestServedBefore = today.AddDays(150)}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var context = new Context())
|
||||
{
|
||||
context.Database.EnsureDeleted();
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
for (var i = 0; i < 1024; i++)
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
var from = today.AddDays(110);
|
||||
|
||||
using var context = new Context();
|
||||
|
||||
var query1 = context.IceCreams
|
||||
.Where(c => c.Name == "Vanilla")
|
||||
.Select(c => c.Brand)
|
||||
.Union(
|
||||
context.IceCreams
|
||||
.Where(c => c.BestServedBefore > from)
|
||||
.Select(c => c.Brand))
|
||||
.ToList();
|
||||
|
||||
var boolean = false;
|
||||
|
||||
var query2 = context.IceCreams
|
||||
.Select(c => new {f = boolean})
|
||||
.ToList();
|
||||
|
||||
boolean = true;
|
||||
|
||||
var query3 = context.IceCreams
|
||||
.Select(c => new {f = boolean})
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
catch (AccessViolationException e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Platforms>AnyCPU;x86;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="$(MicrosoftExtensionsConfigurationEnvironmentVariablesVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionsConfigurationFileExtensionsVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsConfigurationJsonVersion)" />
|
||||
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(LocalEFCoreRepository)' == ''">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(MicrosoftEntityFrameworkCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(LocalEFCoreRepository)' != ''">
|
||||
<Reference Include="Microsoft.EntityFrameworkCore">
|
||||
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational.Specification.Tests\Debug\$(TargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.EntityFrameworkCore.Abstractions">
|
||||
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational.Specification.Tests\Debug\$(TargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.EntityFrameworkCore.Analyzers">
|
||||
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational.Specification.Tests\Debug\$(TargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.EntityFrameworkCore.Design">
|
||||
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Design\Debug\$(DefaultNetStandardTargetFramework)\Microsoft.EntityFrameworkCore.Design.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.EntityFrameworkCore.Proxies">
|
||||
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational.Specification.Tests\Debug\$(TargetFramework)\Microsoft.EntityFrameworkCore.Proxies.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.EntityFrameworkCore.Relational">
|
||||
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational.Specification.Tests\Debug\$(TargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests">
|
||||
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational.Specification.Tests\Debug\$(TargetFramework)\Microsoft.EntityFrameworkCore.Relational.Specification.Tests.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.EntityFrameworkCore.Specification.Tests">
|
||||
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational.Specification.Tests\Debug\$(TargetFramework)\Microsoft.EntityFrameworkCore.Specification.Tests.dll</HintPath>
|
||||
</Reference>
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(MicrosoftExtensionsCachingMemoryVersion)" />
|
||||
<PackageReference Include="NetTopologySuite" Version="$(NetTopologySuiteVersion)" />
|
||||
<PackageReference Include="System.ComponentModel.TypeConverter" Version="$(SystemComponentModelTypeConverterVersion)" />
|
||||
<PackageReference Include="Castle.Core" Version="$(CastleCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\EFCore.Jet\EFCore.Jet.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Northwind.accdb">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Data.Jet;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JetProviderExceptionTests
|
||||
{
|
||||
public class NorthwindTestEFCore
|
||||
{
|
||||
public class Customer
|
||||
{
|
||||
public string CustomerID { get; set; }
|
||||
public string CompanyName { get; set; }
|
||||
public string ContactName { get; set; }
|
||||
public string ContactTitle { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Region { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Fax { get; set; }
|
||||
}
|
||||
|
||||
public class Context : DbContext
|
||||
{
|
||||
public DbSet<Customer> Customers { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder
|
||||
.UseJet("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Northwind.accdb", JetConfiguration.DefaultProviderFactory)
|
||||
.UseLoggerFactory(
|
||||
LoggerFactory.Create(
|
||||
b => b
|
||||
.AddConsole()
|
||||
.AddFilter(level => level >= LogLevel.Information)))
|
||||
.EnableSensitiveDataLogging()
|
||||
.EnableDetailedErrors();
|
||||
}
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
using var context = new Context();
|
||||
|
||||
for (var j = 0; j < 12; j++)
|
||||
{
|
||||
//
|
||||
// Select_Union:
|
||||
//
|
||||
|
||||
var query1 = context.Set<Customer>()
|
||||
.Where(c => c.City == "Berlin")
|
||||
.Select(c => c.Address)
|
||||
.Union(
|
||||
context.Set<Customer>()
|
||||
.Where(c => c.City == "London")
|
||||
.Select(c => c.Address))
|
||||
.ToList();
|
||||
|
||||
//
|
||||
// Select_bool_closure:
|
||||
//
|
||||
|
||||
var boolean = false;
|
||||
|
||||
var query2 = context.Set<Customer>()
|
||||
.Select(c => new {f = boolean})
|
||||
.ToList();
|
||||
|
||||
boolean = true;
|
||||
|
||||
var query3 = context.Set<Customer>()
|
||||
.Select(c => new {f = boolean})
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AccessViolationException e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Data.Jet;
|
||||
|
||||
namespace JetProviderExceptionTests
|
||||
{
|
||||
public class NorthwindTestJetCommand
|
||||
{
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
using var connection = new JetConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Northwind.accdb");
|
||||
connection.Open();
|
||||
|
||||
for (var j = 0; j < 2000; j++)
|
||||
{
|
||||
Console.WriteLine($"{i:00}: {j:000}");
|
||||
|
||||
//
|
||||
// Select_Union:
|
||||
//
|
||||
|
||||
using (var command1 = connection.CreateCommand())
|
||||
{
|
||||
command1.CommandText = @"SELECT `c`.`Address`
|
||||
FROM `Customers` AS `c`
|
||||
WHERE `c`.`City` = 'Berlin'
|
||||
UNION
|
||||
SELECT `c0`.`Address`
|
||||
FROM `Customers` AS `c0`
|
||||
WHERE `c0`.`City` = 'London'";
|
||||
|
||||
using (var dataReader1 = command1.ExecuteReader())
|
||||
{
|
||||
while (dataReader1.Read())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Select_bool_closure:
|
||||
//
|
||||
|
||||
using (var command2 = connection.CreateCommand())
|
||||
{
|
||||
command2.CommandText = @"SELECT 1
|
||||
FROM `Customers` AS `c`";
|
||||
|
||||
using (var dataReader2 = command2.ExecuteReader())
|
||||
{
|
||||
while (dataReader2.Read())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AccessViolationException e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
Console.ReadKey(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace JetProviderExceptionTests
|
||||
{
|
||||
public class NorthwindTestOleDbCommand
|
||||
{
|
||||
public void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.16.0;Data Source=Northwind.accdb");
|
||||
connection.Open();
|
||||
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Console.WriteLine($"{i:000}");
|
||||
|
||||
//
|
||||
// Select_Union:
|
||||
//
|
||||
|
||||
using (var command1 = connection.CreateCommand())
|
||||
{
|
||||
command1.CommandText = @"SELECT `c`.`Address`
|
||||
FROM `Customers` AS `c`
|
||||
WHERE `c`.`City` = 'Berlin'
|
||||
UNION
|
||||
SELECT `c0`.`Address`
|
||||
FROM `Customers` AS `c0`
|
||||
WHERE `c0`.`City` = 'London'";
|
||||
|
||||
using (var dataReader1 = command1.ExecuteReader())
|
||||
{
|
||||
while (dataReader1.Read())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
using (var command15 = connection.CreateCommand())
|
||||
{
|
||||
command15.CommandText = @"SELECT [c].[Address]
|
||||
FROM [Customers] AS [c]
|
||||
WHERE [c].[City] = 'Madrid'";
|
||||
|
||||
using (var dataReader15 = command15.ExecuteReader())
|
||||
{
|
||||
while (dataReader15.Read())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//
|
||||
// Select_bool_closure:
|
||||
//
|
||||
|
||||
using (var command2 = connection.CreateCommand())
|
||||
{
|
||||
command2.CommandText = @"SELECT 1
|
||||
FROM `Customers` AS `c`";
|
||||
|
||||
using (var dataReader2 = command2.ExecuteReader())
|
||||
{
|
||||
while (dataReader2.Read())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AccessViolationException e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue