mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Support Sqlserver tree
This commit is contained in:
parent
cca7cb0fbb
commit
529d35c8d4
15
Src/Asp.Net/SqlServerTest/Models/TestTree.cs
Normal file
15
Src/Asp.Net/SqlServerTest/Models/TestTree.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public class TestTree
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(ColumnDataType = "hierarchyid")]
|
||||||
|
public string TreeId { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -87,6 +87,7 @@
|
|||||||
<Compile Include="OldTest\Demos\K_MultiClient.cs" />
|
<Compile Include="OldTest\Demos\K_MultiClient.cs" />
|
||||||
<Compile Include="OldTest\Models\Brand.cs" />
|
<Compile Include="OldTest\Models\Brand.cs" />
|
||||||
<Compile Include="OldTest\BugTest\Bug1.cs" />
|
<Compile Include="OldTest\BugTest\Bug1.cs" />
|
||||||
|
<Compile Include="Models\TestTree.cs" />
|
||||||
<Compile Include="OldTest\Models\VendorAndBrand.cs" />
|
<Compile Include="OldTest\Models\VendorAndBrand.cs" />
|
||||||
<Compile Include="OldTest\Demos\F_VersionValidation.cs" />
|
<Compile Include="OldTest\Demos\F_VersionValidation.cs" />
|
||||||
<Compile Include="OldTest\Demos\G_Mapper.cs" />
|
<Compile Include="OldTest\Demos\G_Mapper.cs" />
|
||||||
|
@ -16,11 +16,15 @@ namespace OrmTest
|
|||||||
var totalPage = 0;
|
var totalPage = 0;
|
||||||
var list=Db.Queryable<Order>().ToPageList(pageindex, pagesize, ref total, ref totalPage);
|
var list=Db.Queryable<Order>().ToPageList(pageindex, pagesize, ref total, ref totalPage);
|
||||||
|
|
||||||
Db.CodeFirst.InitTables(typeof(CarType));
|
//Db.CodeFirst.InitTables(typeof(CarType));
|
||||||
Db.Updateable<CarType>()
|
//Db.Updateable<CarType>()
|
||||||
.SetColumns(it => new CarType { State =SqlSugar.SqlFunc.IIF(it.State==true,false,true) }).Where(it=>true)
|
// .SetColumns(it => new CarType { State =SqlSugar.SqlFunc.IIF(it.State==true,false,true) }).Where(it=>true)
|
||||||
.ExecuteCommand();
|
// .ExecuteCommand();
|
||||||
|
|
||||||
|
//Db.CodeFirst.InitTables(typeof(TestTree));
|
||||||
|
//Db.DbMaintenance.TruncateTable<TestTree>();
|
||||||
|
//Db.Ado.ExecuteCommand("insert testtree values(hierarchyid::GetRoot(),'name')");
|
||||||
|
//var list2 = Db.Queryable<TestTree>().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,6 +151,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return "long";
|
return "long";
|
||||||
}
|
}
|
||||||
|
else if (dbTypeName.Contains("hierarchyid"))
|
||||||
|
{
|
||||||
|
return "object";
|
||||||
|
}
|
||||||
else if (dbTypeName == "int16")
|
else if (dbTypeName == "int16")
|
||||||
{
|
{
|
||||||
return "short";
|
return "short";
|
||||||
|
@ -26,7 +26,6 @@ namespace SqlSugar
|
|||||||
private IDataReaderEntityBuilder<T> DynamicBuilder;
|
private IDataReaderEntityBuilder<T> DynamicBuilder;
|
||||||
private IDataRecord DataRecord;
|
private IDataRecord DataRecord;
|
||||||
private static readonly MethodInfo isDBNullMethod = typeof(IDataRecord).GetMethod("IsDBNull", new Type[] { typeof(int) });
|
private static readonly MethodInfo isDBNullMethod = typeof(IDataRecord).GetMethod("IsDBNull", new Type[] { typeof(int) });
|
||||||
private static readonly MethodInfo getValueMethod = typeof(IDataRecord).GetMethod("get_Item", new Type[] { typeof(int) });
|
|
||||||
private static readonly MethodInfo getBoolean = typeof(IDataRecord).GetMethod("GetBoolean", new Type[] { typeof(int) });
|
private static readonly MethodInfo getBoolean = typeof(IDataRecord).GetMethod("GetBoolean", new Type[] { typeof(int) });
|
||||||
private static readonly MethodInfo getByte = typeof(IDataRecord).GetMethod("GetByte", new Type[] { typeof(int) });
|
private static readonly MethodInfo getByte = typeof(IDataRecord).GetMethod("GetByte", new Type[] { typeof(int) });
|
||||||
private static readonly MethodInfo getDateTime = typeof(IDataRecord).GetMethod("GetDateTime", new Type[] { typeof(int) });
|
private static readonly MethodInfo getDateTime = typeof(IDataRecord).GetMethod("GetDateTime", new Type[] { typeof(int) });
|
||||||
@ -38,6 +37,7 @@ namespace SqlSugar
|
|||||||
private static readonly MethodInfo getInt32 = typeof(IDataRecord).GetMethod("GetInt32", new Type[] { typeof(int) });
|
private static readonly MethodInfo getInt32 = typeof(IDataRecord).GetMethod("GetInt32", new Type[] { typeof(int) });
|
||||||
private static readonly MethodInfo getInt64 = typeof(IDataRecord).GetMethod("GetInt64", new Type[] { typeof(int) });
|
private static readonly MethodInfo getInt64 = typeof(IDataRecord).GetMethod("GetInt64", new Type[] { typeof(int) });
|
||||||
private static readonly MethodInfo getString = typeof(IDataRecord).GetMethod("GetString", new Type[] { typeof(int) });
|
private static readonly MethodInfo getString = typeof(IDataRecord).GetMethod("GetString", new Type[] { typeof(int) });
|
||||||
|
private static readonly MethodInfo getValueMethod = typeof(IDataRecordExtensions).GetMethod("SugarGetValue");
|
||||||
private static readonly MethodInfo getdatetimeoffset = typeof(IDataRecordExtensions).GetMethod("Getdatetimeoffset");
|
private static readonly MethodInfo getdatetimeoffset = typeof(IDataRecordExtensions).GetMethod("Getdatetimeoffset");
|
||||||
private static readonly MethodInfo getdatetimeoffsetDate = typeof(IDataRecordExtensions).GetMethod("GetdatetimeoffsetDate");
|
private static readonly MethodInfo getdatetimeoffsetDate = typeof(IDataRecordExtensions).GetMethod("GetdatetimeoffsetDate");
|
||||||
private static readonly MethodInfo getStringGuid = typeof(IDataRecordExtensions).GetMethod("GetStringGuid");
|
private static readonly MethodInfo getStringGuid = typeof(IDataRecordExtensions).GetMethod("GetStringGuid");
|
||||||
|
@ -136,7 +136,19 @@ namespace SqlSugar
|
|||||||
var result = dr.GetInt32(i);
|
var result = dr.GetInt32(i);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public static object SugarGetValue(this IDataRecord dr, int i)
|
||||||
|
{
|
||||||
|
if (dr.IsDBNull(i))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var result = dr.GetValue(i);
|
||||||
|
if (result.GetType().Name == "SqlHierarchyId")
|
||||||
|
{
|
||||||
|
result = result.ObjToString();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public static long? GetConvetInt64(this IDataRecord dr, int i)
|
public static long? GetConvetInt64(this IDataRecord dr, int i)
|
||||||
{
|
{
|
||||||
if (dr.IsDBNull(i))
|
if (dr.IsDBNull(i))
|
||||||
|
Loading…
Reference in New Issue
Block a user