mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-24 04:53:45 +08:00
Modifying Demo
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using Admin.NET.Application;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Data;
|
||||
public class UnitInsertNavOneToOne
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var db = new SqlSugarScope(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConnectionString = "server=.;uid=sa;pwd=sasa;database=Question",
|
||||
DbType = SqlSugar.DbType.SqlServer,
|
||||
IsAutoCloseConnection = true
|
||||
});
|
||||
db.DbMaintenance.CreateDatabase();
|
||||
//建表
|
||||
if (!db.DbMaintenance.IsAnyTable("SysField", false) &&
|
||||
!db.DbMaintenance.IsAnyTable("SysFormField", false) &&
|
||||
!db.DbMaintenance.IsAnyTable("SysFormUpload", false))
|
||||
{
|
||||
db.CodeFirst.InitTables<SysField>();
|
||||
db.CodeFirst.InitTables<SysFormField>();
|
||||
db.CodeFirst.InitTables<SysFormUpload>();
|
||||
}
|
||||
|
||||
|
||||
//用例代码
|
||||
|
||||
SysFormField addSysFormFieldInput = new SysFormField()
|
||||
{
|
||||
FieldId = 0,
|
||||
Order = 0,
|
||||
DefaultValue = "",
|
||||
FieldName = "",
|
||||
|
||||
FieldTypeName = "",
|
||||
FieldAlias = "",
|
||||
|
||||
UpdateUserId=1,
|
||||
CreateUserId=1,
|
||||
IsDelete=false,
|
||||
FormUpload=new SysFormUpload() { CreateUserId=1, CreateTime =DateTime.Now,UpdateTime=DateTime.Now},
|
||||
SysField=new SysField() { Order=1, CreateUserId=2, FieldTypeName ="a", FieldName="a", UpdateTime=DateTime.Now, CreateTime=DateTime.Now},
|
||||
CreateTime=DateTime.Now,
|
||||
UpdateTime=DateTime.Now
|
||||
|
||||
};
|
||||
|
||||
var entity = addSysFormFieldInput;
|
||||
|
||||
db.InsertNav(entity)
|
||||
.Include(x => x.SysField)
|
||||
.Include(x => x.FormUpload)
|
||||
.ExecuteCommand();
|
||||
db.Queryable<SysFormField>()
|
||||
.Select(it => new xxx
|
||||
{
|
||||
id = 1,
|
||||
NAME= it.SysField.FieldName+":"+it.FieldName.ToString()
|
||||
}).ToList();
|
||||
Console.WriteLine("用例跑完");
|
||||
// Console.ReadKey();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class xxx
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string NAME { get; set; }
|
||||
}
|
Reference in New Issue
Block a user