Support Sqlserver tree

This commit is contained in:
sunkaixuan
2019-05-23 19:25:51 +08:00
parent cca7cb0fbb
commit 529d35c8d4
6 changed files with 42 additions and 6 deletions

View 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; }
}
}

View File

@@ -87,6 +87,7 @@
<Compile Include="OldTest\Demos\K_MultiClient.cs" />
<Compile Include="OldTest\Models\Brand.cs" />
<Compile Include="OldTest\BugTest\Bug1.cs" />
<Compile Include="Models\TestTree.cs" />
<Compile Include="OldTest\Models\VendorAndBrand.cs" />
<Compile Include="OldTest\Demos\F_VersionValidation.cs" />
<Compile Include="OldTest\Demos\G_Mapper.cs" />

View File

@@ -16,11 +16,15 @@ namespace OrmTest
var totalPage = 0;
var list=Db.Queryable<Order>().ToPageList(pageindex, pagesize, ref total, ref totalPage);
Db.CodeFirst.InitTables(typeof(CarType));
Db.Updateable<CarType>()
.SetColumns(it => new CarType { State =SqlSugar.SqlFunc.IIF(it.State==true,false,true) }).Where(it=>true)
.ExecuteCommand();
//Db.CodeFirst.InitTables(typeof(CarType));
//Db.Updateable<CarType>()
// .SetColumns(it => new CarType { State =SqlSugar.SqlFunc.IIF(it.State==true,false,true) }).Where(it=>true)
// .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();
}
}
}