mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Add unit test
This commit is contained in:
parent
f6368bab0b
commit
1bfa11facc
@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
UnitOneToOneNAny.Init();
|
||||
Unitrasdfa.Init();
|
||||
Unitadfasdfa.Init();
|
||||
UpdateNavOneToOne.Init();
|
||||
|
19
Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitOneToOneNAny.cs
Normal file
19
Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitOneToOneNAny.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
internal class UnitOneToOneNAny
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var db = NewUnitTest.Db;
|
||||
db.CodeFirst.InitTables<EmpLicenseLogOff, EmpInformation, EmpDepartmentJob,EmpLicense>();
|
||||
db.Queryable<EmpLicenseLogOff>()
|
||||
.Where(it => it.EmpLicense.EmpInformation.EmpDepartmentJobs.Any(z => z.DepId == 1))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
using SqlSugar;
|
||||
using SqlSugar.Extensions;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
/// <summary>
|
||||
///数据实体对象
|
||||
/// @author 作者:曹伟
|
||||
/// @date 2022-12-28 19:37:41
|
||||
/// </summary>
|
||||
[SugarTable("Emp_Department_Job")]
|
||||
public class EmpDepartmentJob
|
||||
{
|
||||
/// <summary>
|
||||
/// 描述 :主键
|
||||
/// 空值 : false /// </summary>
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :人员id
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpId")]
|
||||
public long? EmpId { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :部门id
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "DepId")]
|
||||
public long? DepId { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :岗位id
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "JobId")]
|
||||
public long? JobId { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :是否主部门
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Active")]
|
||||
public bool? Active { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :是否主部门
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsSelect")]
|
||||
public bool? IsSelect { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
using SqlSugar;
|
||||
using SqlSugar.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
/// <summary>
|
||||
///数据实体对象
|
||||
/// @author 作者:曹伟
|
||||
/// @date 2022/11/3 15:30:19
|
||||
/// </summary>
|
||||
[SugarTable("Emp_Information")]
|
||||
public class EmpInformation
|
||||
{
|
||||
/// <summary>
|
||||
/// 描述 :主键
|
||||
/// 空值 : false /// </summary>
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :姓名
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpName")]
|
||||
public string? EmpName { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :性别
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpSex")]
|
||||
public byte? EmpSex { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :身份证号码
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpIdentityCard")]
|
||||
public string? EmpIdentityCard { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :工作证号
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpWorkID")]
|
||||
public string? EmpWorkID { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :公司
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpCompanyId")]
|
||||
public long? EmpCompanyId { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :公司类型 本部1 2委外
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpCompanyType")]
|
||||
public string? EmpCompanyType { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :用工性质
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpNatureValue")]
|
||||
public string? EmpNatureValue { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :手机号码
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpPhoneNumber")]
|
||||
public string? EmpPhoneNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :固定电话
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpFixPhoneNumber")]
|
||||
public string? EmpFixPhoneNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :邮政编码
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpZipCode")]
|
||||
public string? EmpZipCode { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :家庭住址
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpHomeAddress")]
|
||||
public string? EmpHomeAddress { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :户籍地址
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpResidenceAddress")]
|
||||
public string? EmpResidenceAddress { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :所属街道
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpStreet")]
|
||||
public string? EmpStreet { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :民族
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpNationValue")]
|
||||
public string? EmpNationValue { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :政治面貌
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpPoliticalValue")]
|
||||
public string? EmpPoliticalValue { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :账号类型
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpAccountTypeValue")]
|
||||
public string? EmpAccountTypeValue { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :状态 emp_action_status在职 emp_leave_status离职
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpStatusType")]
|
||||
public string? EmpStatusType { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :状态关系
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EmpStatusValue")]
|
||||
public string? EmpStatusValue { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :是否机关各部门老大
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IsJBoss")]
|
||||
public byte? IsJBoss { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateById")]
|
||||
public long? CreateById { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateBy")]
|
||||
public string? CreateBy { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateTime")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateById")]
|
||||
public long? LastUpdateById { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateBy")]
|
||||
public string? LastUpdateBy { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateTime")]
|
||||
public DateTime? LastUpdateTime { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToMany, nameof(EmpDepartmentJob.EmpId))]//部门岗位表中的EmpId
|
||||
public List<EmpDepartmentJob>? EmpDepartmentJobs { get; set; }//注意禁止给手动赋值
|
||||
|
||||
[Navigate(NavigateType.OneToMany, nameof(EmpLicense.IdentityCard), nameof(EmpIdentityCard))]//部门岗位表中的EmpId
|
||||
public List<EmpLicense>? EmpLicenses { get; set; }//注意禁止给手动赋值
|
||||
|
||||
}
|
||||
}
|
158
Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicense.cs
Normal file
158
Src/Asp.NetCore2/SqlSeverTest/UnitTest/Unitasf1/EmpLicense.cs
Normal file
@ -0,0 +1,158 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using SqlSugar.Extensions;
|
||||
using System;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
/// <summary>
|
||||
///数据实体对象
|
||||
/// @author 作者:曹伟
|
||||
/// @date 2023-02-13 18:02:23
|
||||
/// </summary>
|
||||
[SugarTable("Emp_License")]
|
||||
public class EmpLicense
|
||||
{
|
||||
/// <summary>
|
||||
/// 描述 :主键
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :姓名
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Name")]
|
||||
public string? Name { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :身份证号码
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "IdentityCard")]
|
||||
public string? IdentityCard { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :证照类别
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LicenseClassify")]
|
||||
public long? LicenseClassify { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :证照名称
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LicenseValue")]
|
||||
public string? LicenseValue { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :证照编号
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LicenseCode")]
|
||||
public string? LicenseCode { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :证照所属
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LicenseBelong")]
|
||||
public int? LicenseBelong { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :初证日期
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "InitialDate")]
|
||||
public DateTime? InitialDate { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :复证日期
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "RepeatDate")]
|
||||
public DateTime? RepeatDate { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :有效日期
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "EffectiveDate")]
|
||||
public DateTime? EffectiveDate { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :核证日期
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "VerifyDate")]
|
||||
public DateTime? VerifyDate { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :原件位置
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Location")]
|
||||
public string? Location { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :状态
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Status")]
|
||||
public int? Status { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :创建人id
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "OperateById")]
|
||||
public long? OperateById { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :创建人姓名
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "OperateBy")]
|
||||
public string? OperateBy { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :创建时间
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "OperateTime")]
|
||||
public DateTime? OperateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :创建人id
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateById", IsOnlyIgnoreUpdate = true)]
|
||||
public long? CreateById { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :创建人姓名
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateBy", IsOnlyIgnoreUpdate = true)]
|
||||
public string? CreateBy { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :创建时间
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateTime", IsOnlyIgnoreUpdate = true)]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :最后修改人id
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateById", IsOnlyIgnoreInsert = true)]
|
||||
public long? LastUpdateById { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :最后修改人
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateBy", IsOnlyIgnoreInsert = true)]
|
||||
public string? LastUpdateBy { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :最后修改时间
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateTime", IsOnlyIgnoreInsert = true)]
|
||||
public DateTime? LastUpdateTime { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(IdentityCard), nameof(OrmTest.EmpInformation.EmpIdentityCard))] //自定义关系映射
|
||||
public EmpInformation? EmpInformation { get; set; } //只能是null 不能赋默认值
|
||||
|
||||
|
||||
//证照注销信息
|
||||
[Navigate(NavigateType.OneToOne, nameof(Id), nameof(OrmTest.EmpLicenseLogOff.LicenseId))]//
|
||||
public EmpLicenseLogOff? EmpLicenseLogOff { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
using SqlSugar;
|
||||
using SqlSugar.Extensions;
|
||||
using System;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
/// <summary>
|
||||
///数据实体对象
|
||||
/// @author 作者:曹伟
|
||||
/// @date 2023/7/5 17:08:20
|
||||
/// </summary>
|
||||
[SugarTable("Emp_License_LogOff")]
|
||||
public class EmpLicenseLogOff
|
||||
{
|
||||
/// <summary>
|
||||
/// 描述 :主键
|
||||
/// 空值 : false /// </summary>
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :关联自有证照id
|
||||
/// 空值 : false /// </summary>
|
||||
[SugarColumn(ColumnName = "LicenseId")]
|
||||
public long LicenseId { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :证照注销原因
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LogOffReasonValue")]
|
||||
public string? LogOffReasonValue { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :备注
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Remarks")]
|
||||
public string? Remarks { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Status")]
|
||||
public int? Status { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateById")]
|
||||
public long? CreateById { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateBy")]
|
||||
public string? CreateBy { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CreateTime")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateById")]
|
||||
public long? LastUpdateById { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateBy")]
|
||||
public string? LastUpdateBy { get; set; }
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LastUpdateTime")]
|
||||
public DateTime? LastUpdateTime { get; set; }
|
||||
|
||||
|
||||
//委外证照信息
|
||||
[Navigate(NavigateType.OneToOne, nameof(LicenseId), nameof(OrmTest.EmpLicense.Id))]//
|
||||
public EmpLicense? EmpLicense { get; set; }
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user