mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Support enum
This commit is contained in:
parent
eef317a3b7
commit
b9c1567cc7
@ -33,12 +33,6 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="MySql.Data">
|
|
||||||
<HintPath>..\SqlSugar\Lib\MySql.Data.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Newtonsoft.Json">
|
|
||||||
<HintPath>..\SqlSugar\Lib\Newtonsoft.Json.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SyntacticSugar, Version=2.4.1.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="SyntacticSugar, Version=2.4.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\SqlServerTest\OtherDll\SyntacticSugar.dll</HintPath>
|
<HintPath>..\SqlServerTest\OtherDll\SyntacticSugar.dll</HintPath>
|
||||||
|
@ -31,7 +31,7 @@ namespace OrmTest
|
|||||||
new Update(1).Init();
|
new Update(1).Init();
|
||||||
new Mapping(1).Init();
|
new Mapping(1).Init();
|
||||||
new DataTest(1).Init();
|
new DataTest(1).Init();
|
||||||
|
new EnumTest(1).Init();
|
||||||
/***Performance Test***/
|
/***Performance Test***/
|
||||||
new SqlSugarPerformance(100).Select();
|
new SqlSugarPerformance(100).Select();
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
|
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
|
||||||
<Compile Include="UnitTest\DataTest.cs" />
|
<Compile Include="UnitTest\DataTest.cs" />
|
||||||
<Compile Include="UnitTest\Delete.cs" />
|
<Compile Include="UnitTest\Delete.cs" />
|
||||||
|
<Compile Include="UnitTest\EnumTest.cs" />
|
||||||
<Compile Include="UnitTest\UnitTestBase.cs" />
|
<Compile Include="UnitTest\UnitTestBase.cs" />
|
||||||
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
||||||
<Compile Include="UnitTest\Insert.cs" />
|
<Compile Include="UnitTest\Insert.cs" />
|
||||||
|
@ -68,10 +68,5 @@ namespace OrmTest.UnitTest
|
|||||||
throw new Exception("DataTest Error");
|
throw new Exception("DataTest Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,11 +57,5 @@ namespace OrmTest
|
|||||||
new SugarParameter("@id",1)
|
new SugarParameter("@id",1)
|
||||||
}, t6.Key, t6.Value, "Delte t6 error");
|
}, t6.Key, t6.Value, "Delte t6 error");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
Src/Asp.Net/SqlServerTest/UnitTest/EnumTest.cs
Normal file
25
Src/Asp.Net/SqlServerTest/UnitTest/EnumTest.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using OrmTest.Demo;
|
||||||
|
using OrmTest.Models;
|
||||||
|
|
||||||
|
namespace OrmTest.UnitTest
|
||||||
|
{
|
||||||
|
public class EnumTest : UnitTestBase
|
||||||
|
{
|
||||||
|
private EnumTest() { }
|
||||||
|
public EnumTest(int eachCount)
|
||||||
|
{
|
||||||
|
this.Count = eachCount;
|
||||||
|
}
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
var db = GetInstance();
|
||||||
|
var shoolValue = SchoolEnum.HarvardUniversity;
|
||||||
|
var list = db.Queryable<StudentEnum>().AS("student").Where(it => it.SchoolId == shoolValue).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -125,12 +125,6 @@ new List<SugarParameter>() {
|
|||||||
new SugarParameter("@Name","张三")
|
new SugarParameter("@Name","张三")
|
||||||
}, t11.Key, t11.Value, "Insert t11 error");
|
}, t11.Key, t11.Value, "Insert t11 error");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MyStudent {
|
public class MyStudent {
|
||||||
|
@ -37,7 +37,7 @@ namespace OrmTest.UnitTest
|
|||||||
var x2 = GetInstance();
|
var x2 = GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
public new SqlSugarClient GetInstance()
|
||||||
{
|
{
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() {InitKeyType=InitKeyType.Attribute, ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() {InitKeyType=InitKeyType.Attribute, ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
||||||
return db;
|
return db;
|
||||||
|
@ -81,7 +81,7 @@ namespace OrmTest.UnitTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
public new SqlSugarClient GetInstance()
|
||||||
{
|
{
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
|
||||||
db.Ado.IsEnableLogEvent = true;
|
db.Ado.IsEnableLogEvent = true;
|
||||||
|
@ -84,11 +84,5 @@ namespace OrmTest.UnitTest
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,12 +108,5 @@ namespace OrmTest.UnitTest
|
|||||||
new SugarParameter("@InPara0",1) },t9.Key,t9.Value, "single t9 error");
|
new SugarParameter("@InPara0",1) },t9.Key,t9.Value, "single t9 error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,5 @@ namespace OrmTest.UnitTest
|
|||||||
var x = db.Queryable<Student>().ToList();
|
var x = db.Queryable<Student>().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,6 @@ namespace OrmTest.UnitTest
|
|||||||
{
|
{
|
||||||
public class MapColumn : UnitTestBase
|
public class MapColumn : UnitTestBase
|
||||||
{
|
{
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,5 @@ namespace OrmTest.UnitTest
|
|||||||
var x = db.Queryable<Student>().ToList();
|
var x = db.Queryable<Student>().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,5 +45,11 @@ namespace OrmTest.UnitTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SqlSugarClient GetInstance()
|
||||||
|
{
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
||||||
|
return db;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -145,10 +145,5 @@ namespace OrmTest.UnitTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
|
||||||
{
|
|
||||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,6 +174,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var appendValue = this.Context.SqlParameterKeyWord + ExpressionConst.Const + Context.ParameterIndex;
|
var appendValue = this.Context.SqlParameterKeyWord + ExpressionConst.Const + Context.ParameterIndex;
|
||||||
Context.ParameterIndex++;
|
Context.ParameterIndex++;
|
||||||
|
if (value != null && value.GetType().IsEnum) {
|
||||||
|
value = Convert.ToInt64(value);
|
||||||
|
}
|
||||||
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
|
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
|
||||||
appendValue = string.Format(" {0} ", appendValue);
|
appendValue = string.Format(" {0} ", appendValue);
|
||||||
if (isLeft == true)
|
if (isLeft == true)
|
||||||
|
Loading…
Reference in New Issue
Block a user