Skip to content

Commit

Permalink
check
Browse files Browse the repository at this point in the history
  • Loading branch information
soul-soft committed Aug 30, 2019
1 parent e855a4c commit b9ad021
Show file tree
Hide file tree
Showing 33 changed files with 7,280 additions and 18 deletions.
Binary file modified src/Dapper.Linq/.vs/Dapper.Linq/DesignTimeBuild/.dtbcache
Binary file not shown.
Binary file modified src/Dapper.Linq/.vs/Dapper.Linq/v16/.suo
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Dapper.Linq/Dapper.Linq/Dapper.Linq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Dapper" Version="1.60.6" />
<PackageReference Include="Dapper" Version="2.0.4" />
</ItemGroup>
</Project>
13 changes: 4 additions & 9 deletions src/Dapper.Linq/Dapper.Linq/DbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface IDbContext : IDisposable
IQueryable<T> From<T>() where T : class;
IQueryable<T1, T2> From<T1, T2>() where T1 : class where T2 : class;
IQueryable<T1, T2, T3> From<T1, T2, T3>() where T1 : class where T2 : class where T3 : class;
IQueryable<T1, T2, T3, T4> From<T1, T2, T3, T4>() where T1 : class where T2 : class where T3 : class where T4 : class;
GridReader QueryMultiple(string sql, object param = null, int? commandTimeout = null, CommandType text = CommandType.Text);
Task<GridReader> QueryMultipleAsync(string sql, object param = null, int? commandTimeout = null, CommandType text = CommandType.Text);
int Execute(string sql, object param = null, int? commandTimeout = null, CommandType text = CommandType.Text);
Expand All @@ -31,8 +32,8 @@ public interface IDbContext : IDisposable
IDbTransaction Transaction { get; }
DatasourceType SourceType { get; }
DbContextState State { get; }
void Open(bool beginTransaction, IsolationLevel? level = null);
Task OpenAsync(bool beginTransaction, IsolationLevel? level = null);
void Open(bool beginTransaction, IsolationLevel? isolationLevel = null);
Task OpenAsync(bool beginTransaction, IsolationLevel? isolationLevel = null);
void Commit();
void Rollback();
void Close();
Expand Down Expand Up @@ -84,7 +85,7 @@ public async Task OpenAsync(bool beginTransaction, IsolationLevel? level = null)
}
public void Close()
{
Connection.Close();
Connection?.Close();
State = DbContextState.Closed;
}
public void Commit()
Expand Down Expand Up @@ -213,7 +214,6 @@ public Task<IEnumerable<dynamic>> QueryAsync(string sql, object param = null, in
{
return Connection.QueryAsync(sql, param, Transaction, Timeout != null ? Timeout.Value : commandTimeout, commandType);
}

}
public class DbContextProxy : IDbContext
{
Expand All @@ -224,15 +224,10 @@ public DbContextProxy(IDbContext target)
Loggers = new List<Logger>();
}
public List<Logger> Loggers { get; set; }

public IDbConnection Connection => _target.Connection;

public IDbTransaction Transaction => _target.Transaction;

public DbContextState State => _target.State;

public DatasourceType SourceType => _target.SourceType;

public bool? Buffered { get => _target.Buffered; set => _target.Buffered = value; }
public int? Timeout { get => _target.Timeout; set => _target.Timeout = value; }
public void Close()
Expand Down
5 changes: 0 additions & 5 deletions src/Dapper.Linq/Dapper.Linq/EntityUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ private static EntityTable Build(Type type)
identity = columnAttribute.IsIdentity;
columnName = string.IsNullOrEmpty(columnAttribute.Name) ? item.Name : columnAttribute.Name;
}

columns.Add(new EntityColumn()
{
ColumnKey = columnKey,
Expand All @@ -39,26 +38,22 @@ private static EntityTable Build(Type type)
Identity = identity,
});
}

if (columns.Count > 0 && !columns.Exists(e => e.ColumnKey == ColumnKey.Primary))
{
columns[0].ColumnKey = ColumnKey.Primary;
}

var tableName = type.Name;
if (type.GetCustomAttributes(typeof(TableAttribute), true).Length > 0)
{
tableName = (type.GetCustomAttributes(typeof(TableAttribute), true).FirstOrDefault() as TableAttribute).Name;
}

var table = new EntityTable()
{
CSharpName = type.Name,
CSharpType = type,
TableName = tableName,
Columns = columns,
};

lock (_database)
{
if (!_database.Exists(e => e.CSharpType == type))
Expand Down
3 changes: 1 addition & 2 deletions src/Dapper.Linq/Dapper.Linq/ExpressionUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public static Dictionary<string, string> BuildColumns(Expression expression, Dic
{
columnName = GetColumnName(memberExpression1.Expression.Type, memberExpression1.Member.Name, singleTable);
}
else if (argument is MemberExpression memberExpression2 && memberExpression2.Expression.NodeType == ExpressionType.Constant)
else if (argument is MemberExpression memberExpression2 && memberExpression2.Expression != null && memberExpression2.Expression.NodeType == ExpressionType.Constant)
{
var value = GetValue(argument);
if (value is ISqlBuilder sqlBuilder)
Expand Down Expand Up @@ -379,7 +379,6 @@ public static Dictionary<string, string> BuildColumns(Expression expression, Dic
}
return columns;
}

public static Dictionary<string, string> BuildColumn(Expression expression, Dictionary<string, object> param, string prefix, bool singleTable = true)
{
if (expression is LambdaExpression)
Expand Down
5 changes: 4 additions & 1 deletion src/Dapper.Linq/NUnitTestProject1/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ public void GroupBy()
{
try
{
context.From<Student>().Single(s => MysqlFun.Count(1));
context.From<Student>().Single(s => new
{
s.IsDelete
});
var students = context.From<Student>()
.GroupBy(a => a.Age)
.Having(a => MysqlFun.Count(1L) > 2)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("NUnitTestProject1")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("NUnitTestProject1")]
[assembly: System.Reflection.AssemblyTitleAttribute("NUnitTestProject1")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// 由 MSBuild WriteCodeFragment 类生成。

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0df5c0fc9ac331a7dc20a57f9e5037f6345b6185
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
501f687308436b3394663553ac9f76c4068c6401
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\NUnit3.TestAdapter.dll
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\NUnit3.TestAdapter.pdb
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\nunit.engine.netstandard.dll
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\NUnitTestProject1.deps.json
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\NUnitTestProject1.runtimeconfig.json
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\NUnitTestProject1.runtimeconfig.dev.json
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\NUnitTestProject1.dll
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\NUnitTestProject1.pdb
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\Dapper.Linq.dll
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\bin\Debug\netcoreapp2.2\Dapper.Linq.pdb
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\obj\Debug\netcoreapp2.2\NUnitTestProject1.csprojAssemblyReference.cache
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\obj\Debug\netcoreapp2.2\NUnitTestProject1.csproj.CoreCompileInputs.cache
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\obj\Debug\netcoreapp2.2\NUnitTestProject1.AssemblyInfoInputs.cache
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\obj\Debug\netcoreapp2.2\NUnitTestProject1.AssemblyInfo.cs
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\obj\Debug\netcoreapp2.2\NUnitTestProject1.csproj.CopyComplete
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\obj\Debug\netcoreapp2.2\NUnitTestProject1.dll
C:\Dapper.Linq\src\Dapper.Linq\NUnitTestProject1\obj\Debug\netcoreapp2.2\NUnitTestProject1.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"dgSpecHash": "G0STN8qsyUcm1QOEXKLsMLyHl8l8aw8IA36XXvD2RWZVdwpQvyfHU7Dswp4XWJ13ScC03w382sfBBhSc+sXdVA==",
"success": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"format": 1,
"restore": {
"C:\\Dapper.Linq\\src\\Dapper.Linq\\NUnitTestProject1\\NUnitTestProject1.csproj": {}
},
"projects": {
"C:\\Dapper.Linq\\src\\Dapper.Linq\\Dapper.Linq\\Dapper.Linq.csproj": {
"version": "1.0.0.5",
"restore": {
"projectUniqueName": "C:\\Dapper.Linq\\src\\Dapper.Linq\\Dapper.Linq\\Dapper.Linq.csproj",
"projectName": "Dapper.Linq",
"projectPath": "C:\\Dapper.Linq\\src\\Dapper.Linq\\Dapper.Linq\\Dapper.Linq.csproj",
"packagesPath": "C:\\Users\\14483\\.nuget\\packages\\",
"outputPath": "C:\\Dapper.Linq\\src\\Dapper.Linq\\Dapper.Linq\\obj\\",
"projectStyle": "PackageReference",
"crossTargeting": true,
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\14483\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net45",
"netstandard2.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net45": {
"projectReferences": {}
},
"netstandard2.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net45": {
"dependencies": {
"Dapper": {
"target": "Package",
"version": "[1.42.0, )"
}
}
},
"netstandard2.0": {
"dependencies": {
"Dapper": {
"target": "Package",
"version": "[2.0.4, )"
},
"NETStandard.Library": {
"suppressParent": "All",
"target": "Package",
"version": "[2.0.3, )",
"autoReferenced": true
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
},
"C:\\Dapper.Linq\\src\\Dapper.Linq\\NUnitTestProject1\\NUnitTestProject1.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Dapper.Linq\\src\\Dapper.Linq\\NUnitTestProject1\\NUnitTestProject1.csproj",
"projectName": "NUnitTestProject1",
"projectPath": "C:\\Dapper.Linq\\src\\Dapper.Linq\\NUnitTestProject1\\NUnitTestProject1.csproj",
"packagesPath": "C:\\Users\\14483\\.nuget\\packages\\",
"outputPath": "C:\\Dapper.Linq\\src\\Dapper.Linq\\NUnitTestProject1\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\14483\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp2.2"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp2.2": {
"projectReferences": {
"C:\\Dapper.Linq\\src\\Dapper.Linq\\Dapper.Linq\\Dapper.Linq.csproj": {
"projectPath": "C:\\Dapper.Linq\\src\\Dapper.Linq\\Dapper.Linq\\Dapper.Linq.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp2.2": {
"dependencies": {
"Microsoft.NET.Test.Sdk": {
"target": "Package",
"version": "[15.9.0, )"
},
"Microsoft.NETCore.App": {
"suppressParent": "All",
"target": "Package",
"version": "[2.2.0, )",
"autoReferenced": true
},
"MySql.Data": {
"target": "Package",
"version": "[8.0.17, )"
},
"NUnit3TestAdapter": {
"target": "Package",
"version": "[3.11.0, )"
},
"nunit": {
"target": "Package",
"version": "[3.11.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\14483\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.2.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)nunit3testadapter\3.11.0\build\netcoreapp1.0\NUnit3TestAdapter.props" Condition="Exists('$(NuGetPackageRoot)nunit3testadapter\3.11.0\build\netcoreapp1.0\NUnit3TestAdapter.props')" />
<Import Project="$(NuGetPackageRoot)nunit\3.11.0\build\NUnit.props" Condition="Exists('$(NuGetPackageRoot)nunit\3.11.0\build\NUnit.props')" />
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.props" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.codecoverage\15.9.0\build\netstandard1.0\Microsoft.CodeCoverage.props" Condition="Exists('$(NuGetPackageRoot)microsoft.codecoverage\15.9.0\build\netstandard1.0\Microsoft.CodeCoverage.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\15.9.0\build\netcoreapp1.0\Microsoft.Net.Test.Sdk.props" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\15.9.0\build\netcoreapp1.0\Microsoft.Net.Test.Sdk.props')" />
</ImportGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgNewtonsoft_Json Condition=" '$(PkgNewtonsoft_Json)' == '' ">C:\Users\14483\.nuget\packages\newtonsoft.json\9.0.1</PkgNewtonsoft_Json>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\build\netcoreapp2.2\Microsoft.NETCore.App.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.codecoverage\15.9.0\build\netstandard1.0\Microsoft.CodeCoverage.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.codecoverage\15.9.0\build\netstandard1.0\Microsoft.CodeCoverage.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\15.9.0\build\netcoreapp1.0\Microsoft.Net.Test.Sdk.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\15.9.0\build\netcoreapp1.0\Microsoft.Net.Test.Sdk.targets')" />
</ImportGroup>
</Project>
Loading

0 comments on commit b9ad021

Please sign in to comment.