mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-18 22:31:08 +08:00
aecffecae1
* attempt NRT makeover - annotate NRTs on GridReader API - add protected access to some of the GridReader internals - switch GridReader callbacks to be more type-independent docs lib updates; deal with yellow warnings and test failures (SQL server certs and cancellation surfacing differently) fix break simplify proposed GridReader changes to protected OnBeforeGrid and OnAfterGrid[Async] Builds: Bump library versions (#1935) Tests: Upgrade dependencies for Dependabot (#1936) I'll do a pass at all of these later, but getting CVE versions out of the pipe. Resolving 4 alerts here: https://github.com/DapperLib/Dapper/security/dependabot merge and lib updates allow Identity to be constructed on-the-fly inside GridReader fix build warnings include readme rev minor - enable [SkipLocalsInit] everywhere - use NET5_0_OR_GREATER for remoting check # Conflicts: # Dapper/CommandDefinition.cs # Dapper/DefaultTypeMap.cs # Dapper/SqlMapper.Async.cs # Dapper/SqlMapper.IDataReader.cs # Dapper/SqlMapper.Link.cs # Dapper/SqlMapper.cs # Directory.Build.props * shipped, not unshipped * fixup SqlBuilder; use is null / is not null * use central package management (#1949) * Nullable test tweaks * Nuget: let's just remove it! * 2 test fixes from review * fix FindExplicitConstructor * add GetPropertySetterOrThrow * fix NRT on FindConstructor * DapperRow: value is object? * use NotNullWhen * make constructor problem more obvious * test fixes --------- Co-authored-by: Nick Craver <nrcraver@gmail.com>
68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
#if LINQ2SQL
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Xunit;
|
|
|
|
namespace Dapper.Tests
|
|
{
|
|
public sealed class SystemSqlClientLinq2SqlTests : Linq2SqlTests<SystemSqlClientProvider> { }
|
|
#if MSSQLCLIENT
|
|
public sealed class MicrosoftSqlClientLinq2SqlTests : Linq2SqlTests<MicrosoftSqlClientProvider> { }
|
|
#endif
|
|
public abstract class Linq2SqlTests<TProvider> : TestBase<TProvider> where TProvider : DatabaseProvider
|
|
{
|
|
[Fact]
|
|
public void TestLinqBinaryToClass()
|
|
{
|
|
byte[] orig = new byte[20];
|
|
new Random(123456).NextBytes(orig);
|
|
var input = new System.Data.Linq.Binary(orig);
|
|
|
|
var output = connection.Query<WithBinary>("select @input as [Value]", new { input }).First().Value;
|
|
|
|
Assert.Equal(orig, output?.ToArray());
|
|
}
|
|
|
|
[Fact]
|
|
public void TestLinqBinaryRaw()
|
|
{
|
|
byte[] orig = new byte[20];
|
|
new Random(123456).NextBytes(orig);
|
|
var input = new System.Data.Linq.Binary(orig);
|
|
|
|
var output = connection.Query<System.Data.Linq.Binary>("select @input as [Value]", new { input }).First();
|
|
|
|
Assert.Equal(orig, output.ToArray());
|
|
}
|
|
|
|
private class WithBinary
|
|
{
|
|
public System.Data.Linq.Binary? Value { get; set; }
|
|
}
|
|
|
|
private class NoDefaultConstructorWithBinary
|
|
{
|
|
public System.Data.Linq.Binary Value { get; set; }
|
|
public int Ynt { get; set; }
|
|
public NoDefaultConstructorWithBinary(System.Data.Linq.Binary val)
|
|
{
|
|
Value = val;
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void TestNoDefaultConstructorBinary()
|
|
{
|
|
byte[] orig = new byte[20];
|
|
new Random(123456).NextBytes(orig);
|
|
var input = new System.Data.Linq.Binary(orig);
|
|
var output = connection.Query<NoDefaultConstructorWithBinary>("select @input as val", new { input }).First().Value;
|
|
Assert.Equal(orig, output.ToArray());
|
|
}
|
|
}
|
|
}
|
|
#endif
|