mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 21:56:03 +08:00
Update PgSql
This commit is contained in:
parent
941b37aa3b
commit
34824235aa
@ -89,6 +89,7 @@
|
|||||||
<Compile Include="Models\Tree.cs" />
|
<Compile Include="Models\Tree.cs" />
|
||||||
<Compile Include="Models\ViewOrder.cs" />
|
<Compile Include="Models\ViewOrder.cs" />
|
||||||
<Compile Include="Config.cs" />
|
<Compile Include="Config.cs" />
|
||||||
|
<Compile Include="UnitTest\USave.cs" />
|
||||||
<Compile Include="_OldTest\Demos\1_Query.cs" />
|
<Compile Include="_OldTest\Demos\1_Query.cs" />
|
||||||
<Compile Include="_OldTest\Demos\2_Update.cs" />
|
<Compile Include="_OldTest\Demos\2_Update.cs" />
|
||||||
<Compile Include="_OldTest\Demos\3_Insert.cs" />
|
<Compile Include="_OldTest\Demos\3_Insert.cs" />
|
||||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Save();
|
||||||
CodeFirst();
|
CodeFirst();
|
||||||
Updateable();
|
Updateable();
|
||||||
Json();
|
Json();
|
||||||
|
95
Src/Asp.Net/PgSqlTest/UnitTest/USave.cs
Normal file
95
Src/Asp.Net/PgSqlTest/UnitTest/USave.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public partial class NewUnitTest
|
||||||
|
{
|
||||||
|
public static void Save()
|
||||||
|
{
|
||||||
|
Db.CodeFirst.InitTables<UnitSysMenu>();
|
||||||
|
Db.DbMaintenance.TruncateTable<UnitSysMenu>();
|
||||||
|
Db.Saveable<UnitSysMenu>(new UnitSysMenu() { ID="aa", ButtonList="", CreateName="a", CreateTime=DateTime.Now, ImageUrl="", IsDel=true, MenuCode="a", NavigateUrl="a", UpdateName="", Remark="", UpdateTime=DateTime.Now }).ExecuteReturnEntity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class BaseEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true, ColumnDescription = "ID", Length = 32)]
|
||||||
|
public string ID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 删除标记
|
||||||
|
/// </summary>
|
||||||
|
[ SugarColumn(ColumnDescription = "删除标记")]
|
||||||
|
public bool IsDel { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 排序字段
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "排序字段", IsIdentity = true)]
|
||||||
|
public int SortIndex { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 添加操作员
|
||||||
|
/// </summary>
|
||||||
|
[ SugarColumn(ColumnDescription = "添加操作员", Length = 10, IsNullable = true)]
|
||||||
|
public string CreateName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 添加时间
|
||||||
|
/// </summary>
|
||||||
|
[ SugarColumn(ColumnDescription = "添加时间", IsNullable = true)]
|
||||||
|
public DateTime? CreateTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 修改操作员
|
||||||
|
/// </summary>
|
||||||
|
[ SugarColumn(ColumnDescription = "修改操作员", Length = 10, IsNullable = true)]
|
||||||
|
public string UpdateName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
[ SugarColumn(ColumnDescription = "修改时间", IsNullable = true)]
|
||||||
|
public DateTime? UpdateTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "备注", Length = 150, IsNullable = true)]
|
||||||
|
public string Remark { get; set; }
|
||||||
|
}
|
||||||
|
public class UnitSysMenu : BaseEntity
|
||||||
|
{
|
||||||
|
public UnitSysMenu()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 菜单图标
|
||||||
|
/// </summary>
|
||||||
|
[SqlSugar.SugarColumn(Length = 150, ColumnDescription = "菜单图标")]
|
||||||
|
|
||||||
|
public string ImageUrl { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 菜单编码
|
||||||
|
/// </summary>
|
||||||
|
[SqlSugar.SugarColumn(Length = 50, ColumnDescription = "菜单编码")]
|
||||||
|
public string MenuCode { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 菜单地址
|
||||||
|
/// </summary>
|
||||||
|
[ SqlSugar.SugarColumn(Length = 200, IsNullable = true, ColumnDescription = "菜单地址")]
|
||||||
|
public string NavigateUrl { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 菜单功能
|
||||||
|
/// </summary>
|
||||||
|
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||||
|
public string ButtonList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 排序字段
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "排序字段", IsIdentity = true)]
|
||||||
|
public int SortIndex { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InsertBuilder.IsReturnIdentity = true;
|
InsertBuilder.IsReturnIdentity = true;
|
||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault());
|
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt();
|
var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt();
|
||||||
return result;
|
return result;
|
||||||
@ -22,7 +22,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InsertBuilder.IsReturnIdentity = true;
|
InsertBuilder.IsReturnIdentity = true;
|
||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault());
|
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
var obj = await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
var obj = await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
||||||
var result = obj.ObjToInt();
|
var result = obj.ObjToInt();
|
||||||
@ -38,7 +38,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InsertBuilder.IsReturnIdentity = true;
|
InsertBuilder.IsReturnIdentity = true;
|
||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault());
|
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
var result = Convert.ToInt64(Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
|
var result = Convert.ToInt64(Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
|
||||||
return result;
|
return result;
|
||||||
@ -47,7 +47,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
InsertBuilder.IsReturnIdentity = true;
|
InsertBuilder.IsReturnIdentity = true;
|
||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetPrimaryKeys().FirstOrDefault());
|
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
var result = Convert.ToInt64(await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
|
var result = Convert.ToInt64(await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user