Skip to content

Commit

Permalink
- 修复 Reposition.InsertOrUpdate 更新未变化时的 SQL 错误;#1630
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Sep 27, 2023
1 parent 7926429 commit 7122485
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 3 deletions.
253 changes: 252 additions & 1 deletion Examples/base_entity/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ static void Main(string[] args)

.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")

//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")

//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
Expand Down Expand Up @@ -600,6 +600,12 @@ static void Main(string[] args)
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
#endregion

var risWorkListRepo = fsql.GetRepository<EBH_RisWorkList>();
risWorkListRepo.InsertOrUpdate(new EBH_RisWorkList
{
RequisitionID = "xxx"
});

var tqq01 = fsql.Select<User1>().Where(a => a.IsDeleted || a.IsDeleted || a.IsDeleted).ToSql();

fsql.GlobalFilter.Apply<User1>("test01", a => a.IsDeleted == false);
Expand Down Expand Up @@ -2678,4 +2684,249 @@ class FormLocking
{
public string Value { get; set; }
public string Text { get; set; }
}
[JsonObject(MemberSerialization.OptIn), Table(Name = "RIS_WORKLIST")]
public class EBH_RisWorkList
{
[JsonProperty, Column(DbType = "varchar(64)", IsPrimary = true)]
public string RequisitionID { get; set; }

[JsonProperty, Column(Name = "accession_number", DbType = "varchar(32)")]
public string Accession_number { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string Address { get; set; }

[JsonProperty]
public int? AFCID { get; set; }

[JsonProperty, Column(IsIdentity = true)]
public int AutoIndex { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string Birthday { get; set; }

[JsonProperty, Column(DbType = "varchar(8)")]
public string BirthTime { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string CertificateID { get; set; }

[JsonProperty, Column(DbType = "varchar(512)")]
public string CheckSTDescribed { get; set; }

[JsonProperty, Column(DbType = "varchar(2048)")]
public string ClinicDiagnose { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ClinicID { get; set; }

[JsonProperty]
public int? Confidentiality { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string CustomCheckNumber { get; set; }

[JsonProperty]
public int DepartmentID { get; set; }

[JsonProperty]
public int EmergencyID { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string EndoscopyType { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string ExamBodyPart { get; set; }

[JsonProperty]
public int? ExamBodyPartNum { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ExamDate { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string ExamMethod { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ExamParameter { get; set; }

[JsonProperty, Column(Name = "exampath", DbType = "varchar(50)")]
public string Exampath { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ExamTime { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string FamilyTelephe { get; set; }

[JsonProperty, Column(DbType = "varchar(64)")]
public string FeeTypeName { get; set; }

[JsonProperty]
public int? FollowFlag { get; set; }

[JsonProperty]
public int? HaveImage { get; set; }

[JsonProperty]
public int? HaveRemark { get; set; }

[JsonProperty, Column(DbType = "varchar(50)")]
public string HospitalAreaName { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string HospitalID { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ImageName { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string ImagePath { get; set; }

[JsonProperty, Column(Name = "imagequality", DbType = "varchar(32)")]
public string Imagequality { get; set; }

[JsonProperty]
public int? InAdvanceQueue { get; set; }

[JsonProperty]
public int? InDeedQueue { get; set; }

[JsonProperty, Column(Name = "isAddPatient", DbType = "varchar(2)")]
public string IsAddPatient { get; set; }

[JsonProperty, Column(Name = "isChangeDate", DbType = "varchar(2)")]
public string IsChangeDate { get; set; }

[JsonProperty, Column(Name = "isIBD", DbType = "varchar(2)")]
public string IsIBD { get; set; }

[JsonProperty]
public int? IsNotCallNumber { get; set; }

[JsonProperty]
public int? IsNotNOScreen { get; set; }

[JsonProperty, Column(Name = "isOverTime", DbType = "varchar(2)")]
public string IsOverTime { get; set; }

[JsonProperty]
public int? IsPaSSNumber { get; set; }

[JsonProperty, Column(Name = "isSEZCJ", DbType = "varchar(2)")]
public string IsSEZCJ { get; set; }

[JsonProperty]
public int IsSpePatientSign { get; set; }

[JsonProperty]
public int? IsTexu { get; set; }

[JsonProperty, Column(Name = "isZhiLiao", DbType = "varchar(2)")]
public string IsZhiLiao { get; set; }

[JsonProperty]
public DateTime? LastTryForImage { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string MedicalCardNumber { get; set; }

[JsonProperty, Column(DbType = "varchar(4096)")]
public string MedicalHistory { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string MIcardNumber { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ModalityAE { get; set; }

[JsonProperty]
public int? ModalityID { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ModalityName { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ModalityRemark { get; set; }

[JsonProperty]
public int? ModalityRoomID { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ModalityType { get; set; }

[JsonProperty]
public int? NurseStationFlag { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string PathologicID { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string PatientID { get; set; }

[JsonProperty]
public int PatientTypeID { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string PhysicalExamID { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string PhysicianRequirements { get; set; }

[JsonProperty]
public int PrintFlag { get; set; }

[JsonProperty]
public int? PrintNoticeFlag { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string PTN_NAME { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string PY { get; set; }

[JsonProperty]
public int QueueStateID { get; set; }

[JsonProperty, Column(DbType = "varchar(2048)")]
public string Remarks { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ReqDepartment { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ReqHospital { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string ReqPhysician { get; set; }

[JsonProperty]
public int? ResourceID { get; set; }

[JsonProperty]
public int? SendRepFlag { get; set; }

[JsonProperty, Column(Name = "SEX", DbType = "varchar(32)")]
public string Sex { get; set; }

[JsonProperty, Column(DbType = "varchar(50)")]
public string SickbedID { get; set; }

[JsonProperty]
public int? StateID { get; set; }

[JsonProperty]
public int? StationID { get; set; }

[JsonProperty, Column(DbType = "varchar(32)")]
public string Telephone { get; set; }

[JsonProperty]
public double? Weight { get; set; }

[JsonProperty, Column(DbType = "varchar(128)")]
public string WorkStationAddress { get; set; }


}
2 changes: 1 addition & 1 deletion FreeSql.DbContext/DbSet/DbSetAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ async Task<int> DbContextBatchUpdatePrivAsync(EntityState[] ups, bool isLiveUpda

if (data?.Count > 0)
{
if (cuig.Length == _table.Columns.Count)
if (cuig.Length == _table.Columns.Count - _table.Primarys.Length)
return ups.Length == data.Count ? -998 : -997;

var update = this.OrmUpdate(data.Select(a => a.Value)).IgnoreColumns(cuig);
Expand Down
2 changes: 1 addition & 1 deletion FreeSql.DbContext/DbSet/DbSetSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ int DbContextBatchUpdatePriv(EntityState[] ups, bool isLiveUpdate)

if (data?.Count > 0)
{
if (cuig.Length == _table.Columns.Count)
if (cuig.Length == _table.Columns.Count - _table.Primarys.Length)
return ups.Length == data.Count ? -998 : -997;

var update = this.OrmUpdate(data.Select(a => a.Value)).IgnoreColumns(cuig);
Expand Down

0 comments on commit 7122485

Please sign in to comment.