mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
Merge branch 'master' of https://github.com/d4ilys/FreeSql
This commit is contained in:
commit
656ae2f3bb
@ -1,4 +1,4 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<RepositoryUrl>https://github.com/dotnetcore/FreeSql</RepositoryUrl>
|
<RepositoryUrl>https://github.com/dotnetcore/FreeSql</RepositoryUrl>
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
@ -11,7 +11,7 @@
|
|||||||
<!--
|
<!--
|
||||||
经常出于版本交叉问题,暂时关闭,在每个项目上设置版本号
|
经常出于版本交叉问题,暂时关闭,在每个项目上设置版本号
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@ -600,15 +600,30 @@ namespace base_entity
|
|||||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
var updatejoin031sql = fsql.Update<User1>()
|
||||||
|
.Join<UserGroup>(fsql.Select<UserGroup>().Where(a => a.GroupName == "xxx"), (a, b) => a.GroupId == b.Id)
|
||||||
|
.AsTable("t1", null)
|
||||||
|
.Set((a, b) => b.GroupName == a.Username + "b.groupname")
|
||||||
|
.ToSql();
|
||||||
|
|
||||||
|
fsql.CodeFirst.Entity<B11>(e =>
|
||||||
|
{
|
||||||
|
e.Help().Navigate(b => b.a, nameof(B11.Id));
|
||||||
|
});
|
||||||
|
fsql.CodeFirst.Entity<A11>(e => { });
|
||||||
|
|
||||||
|
var a11sql01 = fsql.Select<B11>().Where(a => a.Id == 1).ToSql(a => new { a.Name, AName = a.a.Name });
|
||||||
|
|
||||||
|
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();
|
var tqq01 = fsql.Select<User1>().Where(a => a.IsDeleted || a.IsDeleted || a.IsDeleted).ToSql();
|
||||||
|
|
||||||
fsql.GlobalFilter.Apply<User1>("test01", a => a.IsDeleted == false);
|
fsql.GlobalFilter.Apply<User1>("test01", a => a.IsDeleted == false);
|
||||||
|
|
||||||
var updatejoin031sql = fsql.Update<User1>()
|
|
||||||
.Join<UserGroup>((a, b) => a.GroupId == b.Id)
|
|
||||||
.Set((a, b) => b.GroupName == a.Username + "b.groupname")
|
|
||||||
.ToSql();
|
|
||||||
|
|
||||||
fsql.UseJsonMap();
|
fsql.UseJsonMap();
|
||||||
fsql.Select<MiDevice>().Where(a => a.FormLocking == null).Count();
|
fsql.Select<MiDevice>().Where(a => a.FormLocking == null).Count();
|
||||||
|
|
||||||
@ -2678,4 +2693,261 @@ class FormLocking
|
|||||||
{
|
{
|
||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
public string Text { 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; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public class A11
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class B11
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public A11 a { get; set; }
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net40</TargetFrameworks>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
||||||
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
|
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net70;net60;net50;netcoreapp31;netcoreapp21;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net70;net60;net50;netcoreapp31;netcoreapp21;net45;net40</TargetFrameworks>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net70;net60;net50;netcoreapp31;netcoreapp21;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net70;net60;net50;netcoreapp31;netcoreapp21;net45;net40</TargetFrameworks>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -17,83 +17,27 @@ namespace FreeSql.Tests.Custom.MySql
|
|||||||
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 2, '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(2, '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -109,83 +53,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 2, '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(2, '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -219,29 +107,7 @@ UNION ALL
|
|||||||
//--no primary and yes
|
//--no primary and yes
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '100001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '100002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '100003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '100004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -263,83 +129,27 @@ INSERT INTO `tbioudb022`(`name`) VALUES('00001'), ('00002'), ('00003'), ('00004'
|
|||||||
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 2, '02', '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(2, '02', '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 3 AND a.`id2` = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 4 AND a.`id2` = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 3 AND a.`id2` = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 4 AND a.`id2` = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
||||||
@ -359,83 +169,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '01', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '01', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '011', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '011', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 2, '02', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(2, '02', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '01', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '01', 0, now(3)), (2, '02', 0, now(3)), (3, '03', 0, now(3)), (4, '04', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '001', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '001', 0, now(3)), (2, '002', 0, now(3)), (3, '003', 0, now(3)), (4, '004', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,83 +17,27 @@ namespace FreeSql.Tests.MySqlConnector
|
|||||||
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 2, '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(2, '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -109,83 +53,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 2, '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(2, '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -219,29 +107,7 @@ UNION ALL
|
|||||||
//--no primary and yes
|
//--no primary and yes
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '100001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '100002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '100003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '100004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -263,83 +129,27 @@ INSERT INTO `tbioudb022`(`name`) VALUES('00001'), ('00002'), ('00003'), ('00004'
|
|||||||
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 2, '02', '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(2, '02', '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 3 AND a.`id2` = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 4 AND a.`id2` = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 3 AND a.`id2` = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 4 AND a.`id2` = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
||||||
@ -359,83 +169,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '01', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '01', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '011', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '011', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 2, '02', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(2, '02', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '01', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '01', 0, now(3)), (2, '02', 0, now(3)), (3, '03', 0, now(3)), (4, '04', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '001', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '001', 0, now(3)), (2, '002', 0, now(3)), (3, '003', 0, now(3)), (4, '004', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,83 +17,27 @@ namespace FreeSql.Tests.Odbc.MySql
|
|||||||
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 2, '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(2, '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -109,83 +53,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 2, '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(2, '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -219,29 +107,7 @@ UNION ALL
|
|||||||
//--no primary and yes
|
//--no primary and yes
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '100001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '100002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '100003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '100004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -263,83 +129,27 @@ INSERT INTO `tbioudb022`(`name`) VALUES('00001'), ('00002'), ('00003'), ('00004'
|
|||||||
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 2, '02', '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(2, '02', '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 3 AND a.`id2` = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 4 AND a.`id2` = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 3 AND a.`id2` = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 4 AND a.`id2` = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
||||||
@ -359,83 +169,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '01', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '01', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '011', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '011', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 2, '02', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(2, '02', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '01', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '01', 0, now(3)), (2, '02', 0, now(3)), (3, '03', 0, now(3)), (4, '04', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '001', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '001', 0, now(3)), (2, '002', 0, now(3)), (3, '003', 0, now(3)), (4, '004', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,83 +17,27 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 1, '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(1, '01')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 1, '011'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(1, '011')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 2, '02'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(2, '02')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 1, '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 1, '001'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -109,83 +53,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '01')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '011'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '011')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 2, '02'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(2, '02')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '001'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -219,29 +107,7 @@ UNION ALL
|
|||||||
//--no primary and yes
|
//--no primary and yes
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '100001'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '100002'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '100003'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '100004'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -263,83 +129,27 @@ INSERT INTO ""tbioudb022""(""name"") VALUES('00001'), ('00002'), ('00003'), ('00
|
|||||||
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 1 AND a.""id2"" = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 1, '01', '011'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '011')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 1 AND a.""id2"" = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 2, '02', '02'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(2, '02', '02')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 2 AND a.""id2"" = '02')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 1 AND a.""id2"" = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '02'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 2 AND a.""id2"" = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '03'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 3 AND a.""id2"" = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '04'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 4 AND a.""id2"" = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 1, '01', '001'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 1 AND a.""id2"" = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '002'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 2 AND a.""id2"" = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '003'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 3 AND a.""id2"" = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '004'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 4 AND a.""id2"" = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
||||||
@ -359,83 +169,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 1, '01', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 1, '011', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '011', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 2, '02', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(2, '02', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 1, '01', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime')), (2, '02', 0, datetime(current_timestamp,'localtime')), (3, '03', 0, datetime(current_timestamp,'localtime')), (4, '04', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 1, '001', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '001', 0, datetime(current_timestamp,'localtime')), (2, '002', 0, datetime(current_timestamp,'localtime')), (3, '003', 0, datetime(current_timestamp,'localtime')), (4, '004', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -16,27 +16,27 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
fsql.Delete<tbiou01>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou01>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
var iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(1)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(1)", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(1)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(1)", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 2 });
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 2 });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(2)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(2)", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(1), (2), (3), (4)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(1), (2), (3), (4)", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(1), (2), (3), (4)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(1), (2), (3), (4)", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
}
|
}
|
||||||
class tbiou01
|
class tbiou01
|
||||||
@ -50,27 +50,27 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
fsql.Delete<tbiou02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou02>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '01')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '01')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '011')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '011')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(2, '02')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(2, '02')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "01" }, new tbiou02 { id = 2, name = "02" }, new tbiou02 { id = 3, name = "03" }, new tbiou02 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "01" }, new tbiou02 { id = 2, name = "02" }, new tbiou02 { id = 3, name = "03" }, new tbiou02 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "001" }, new tbiou02 { id = 2, name = "002" }, new tbiou02 { id = 3, name = "003" }, new tbiou02 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "001" }, new tbiou02 { id = 2, name = "002" }, new tbiou02 { id = 3, name = "003" }, new tbiou02 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbiou02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbiou02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
@ -87,27 +87,27 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
fsql.Delete<tbiou022>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou022>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '01')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '01')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '011')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '011')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(2, '02')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(2, '02')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "01" }, new tbiou022 { id = 2, name = "02" }, new tbiou022 { id = 3, name = "03" }, new tbiou022 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "01" }, new tbiou022 { id = 2, name = "02" }, new tbiou022 { id = 3, name = "03" }, new tbiou022 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "001" }, new tbiou022 { id = 2, name = "002" }, new tbiou022 { id = 3, name = "003" }, new tbiou022 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "001" }, new tbiou022 { id = 2, name = "002" }, new tbiou022 { id = 3, name = "003" }, new tbiou022 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbiou022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbiou022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
@ -141,7 +141,7 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
//--no primary and yes
|
//--no primary and yes
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "100001" }, new tbiou022 { name = "00001" }, new tbiou022 { id = 2, name = "100002" }, new tbiou022 { name = "00002" }, new tbiou022 { id = 3, name = "100003" }, new tbiou022 { name = "00003" }, new tbiou022 { id = 4, name = "100004" }, new tbiou022 { name = "00004" } });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "100001" }, new tbiou022 { name = "00001" }, new tbiou022 { id = 2, name = "100002" }, new tbiou022 { name = "00002" }, new tbiou022 { id = 3, name = "100003" }, new tbiou022 { name = "00003" }, new tbiou022 { id = 4, name = "100004" }, new tbiou022 { name = "00004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -163,27 +163,27 @@ INSERT INTO ""tbiou022""(""name"") VALUES('00001'), ('00002'), ('00003'), ('0000
|
|||||||
fsql.Delete<tbiou03>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou03>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "01" });
|
var iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "011" });
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '011')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '011')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 2, id2 = "02", name = "02" });
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(2, '02', '02')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(2, '02', '02')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "01" }, new tbiou03 { id1 = 2, id2 = "02", name = "02" }, new tbiou03 { id1 = 3, id2 = "03", name = "03" }, new tbiou03 { id1 = 4, id2 = "04", name = "04" } });
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "01" }, new tbiou03 { id1 = 2, id2 = "02", name = "02" }, new tbiou03 { id1 = 3, id2 = "03", name = "03" }, new tbiou03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "001" }, new tbiou03 { id1 = 2, id2 = "02", name = "002" }, new tbiou03 { id1 = 3, id2 = "03", name = "003" }, new tbiou03 { id1 = 4, id2 = "04", name = "004" } });
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "001" }, new tbiou03 { id1 = 2, id2 = "02", name = "002" }, new tbiou03 { id1 = 3, id2 = "03", name = "003" }, new tbiou03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbiou03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
var lst = fsql.Select<tbiou03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id1).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id1).Count());
|
||||||
@ -203,27 +203,27 @@ INSERT INTO ""tbiou022""(""name"") VALUES('00001'), ('00002'), ('00003'), ('0000
|
|||||||
fsql.Delete<tbiou04>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou04>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '011', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '011', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(2, '02', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(2, '02', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "01" }, new tbiou04 { id = 2, name = "02" }, new tbiou04 { id = 3, name = "03" }, new tbiou04 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "01" }, new tbiou04 { id = 2, name = "02" }, new tbiou04 { id = 3, name = "03" }, new tbiou04 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime')), (2, '02', 0, datetime(current_timestamp,'localtime')), (3, '03', 0, datetime(current_timestamp,'localtime')), (4, '04', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime')), (2, '02', 0, datetime(current_timestamp,'localtime')), (3, '03', 0, datetime(current_timestamp,'localtime')), (4, '04', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "001" }, new tbiou04 { id = 2, name = "002" }, new tbiou04 { id = 3, name = "003" }, new tbiou04 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "001" }, new tbiou04 { id = 2, name = "002" }, new tbiou04 { id = 3, name = "003" }, new tbiou04 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '001', 0, datetime(current_timestamp,'localtime')), (2, '002', 0, datetime(current_timestamp,'localtime')), (3, '003', 0, datetime(current_timestamp,'localtime')), (4, '004', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '001', 0, datetime(current_timestamp,'localtime')), (2, '002', 0, datetime(current_timestamp,'localtime')), (3, '003', 0, datetime(current_timestamp,'localtime')), (4, '004', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbiou04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbiou04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
|
@ -28,11 +28,7 @@ namespace FreeSql.Tests.Issues
|
|||||||
.SetSource(new[] { new Song_Tag { SongId = 1, TagId = 1 } })
|
.SetSource(new[] { new Song_Tag { SongId = 1, TagId = 1 } })
|
||||||
.IfExistsDoNothing()
|
.IfExistsDoNothing()
|
||||||
.ToSql();
|
.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `Song_Tag663`(`SongId`, `TagId`) SELECT 1, 1
|
Assert.Equal(@"INSERT IGNORE INTO `Song_Tag663`(`SongId`, `TagId`) VALUES(1, 1)", rst);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `Song_Tag663` a
|
|
||||||
WHERE (a.`SongId` = 1 AND a.`TagId` = 1)
|
|
||||||
limit 0,1)", rst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Table(Name = "Song663")]
|
[Table(Name = "Song663")]
|
||||||
|
@ -111,7 +111,7 @@ WHERE (strftime('%Y',a."CreateTime") = 2021)
|
|||||||
Assert.Single(dmonth1);
|
Assert.Single(dmonth1);
|
||||||
Assert.Single(d1);
|
Assert.Single(d1);
|
||||||
Assert.Single(d1);
|
Assert.Single(d1);
|
||||||
Assert.Single(d5);
|
//Assert.Single(d5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,83 +17,27 @@ namespace FreeSql.Tests.MySql
|
|||||||
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 2, '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(2, '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb02`(`id`, `name`) SELECT 1, '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb02`(`id`, `name`) VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb02` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -109,83 +53,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 2, '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(2, '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -219,29 +107,7 @@ UNION ALL
|
|||||||
//--no primary and yes
|
//--no primary and yes
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb022`(`id`, `name`) SELECT 1, '100001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb022`(`id`, `name`) VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '100002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '100003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '100004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb022` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -263,83 +129,27 @@ INSERT INTO `tbioudb022`(`name`) VALUES('00001'), ('00002'), ('00003'), ('00004'
|
|||||||
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '01')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '011'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '011')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 2, '02', '02'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(2, '02', '02')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '02'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '03'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 3 AND a.`id2` = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '04'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 4 AND a.`id2` = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb03`(`id1`, `id2`, `name`) SELECT 1, '01', '001'
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb03`(`id1`, `id2`, `name`) VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 1 AND a.`id2` = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '002'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 2 AND a.`id2` = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '003'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 3 AND a.`id2` = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '004'
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb03` a
|
|
||||||
WHERE (a.`id1` = 4 AND a.`id2` = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
||||||
@ -359,83 +169,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '01', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '01', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '011', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '011', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 2, '02', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(2, '02', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '01', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '01', 0, now(3)), (2, '02', 0, now(3)), (3, '03', 0, now(3)), (4, '04', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) SELECT 1, '001', 0, now(3)
|
Assert.Equal(@"INSERT IGNORE INTO `tbioudb04`(`id`, `name`, `version`, `CreateTime`) VALUES(1, '001', 0, now(3)), (2, '002', 0, now(3)), (3, '003', 0, now(3)), (4, '004', 0, now(3))", sql);
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004', 0, now(3)
|
|
||||||
FROM dual WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM `tbioudb04` a
|
|
||||||
WHERE (a.`id` = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,83 +17,27 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb02>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 1, '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(1, '01')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 1, '011'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(1, '011')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new tbioudb02 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 2, '02'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(2, '02')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "01" }, new tbioudb02 { id = 2, name = "02" }, new tbioudb02 { id = 3, name = "03" }, new tbioudb02 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 1, '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb02>().IfExistsDoNothing().SetSource(new[] { new tbioudb02 { id = 1, name = "001" }, new tbioudb02 { id = 2, name = "002" }, new tbioudb02 { id = 3, name = "003" }, new tbioudb02 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb02""(""id"", ""name"") SELECT 1, '001'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb02""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb02"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -109,83 +53,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb022>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '01')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '011'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '011')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new tbioudb022 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 2, '02'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(2, '02')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "01" }, new tbioudb022 { id = 2, name = "02" }, new tbioudb022 { id = 3, name = "03" }, new tbioudb022 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "001" }, new tbioudb022 { id = 2, name = "002" }, new tbioudb022 { id = 3, name = "003" }, new tbioudb022 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '001'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
@ -219,29 +107,7 @@ UNION ALL
|
|||||||
//--no primary and yes
|
//--no primary and yes
|
||||||
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
iou = fsql.InsertOrUpdate<tbioudb022>().IfExistsDoNothing().SetSource(new[] { new tbioudb022 { id = 1, name = "100001" }, new tbioudb022 { name = "00001" }, new tbioudb022 { id = 2, name = "100002" }, new tbioudb022 { name = "00002" }, new tbioudb022 { id = 3, name = "100003" }, new tbioudb022 { name = "00003" }, new tbioudb022 { id = 4, name = "100004" }, new tbioudb022 { name = "00004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb022""(""id"", ""name"") SELECT 1, '100001'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb022""(""id"", ""name"") VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '100002'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '100003'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '100004'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb022"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -263,83 +129,27 @@ INSERT INTO ""tbioudb022""(""name"") VALUES('00001'), ('00002'), ('00003'), ('00
|
|||||||
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb03>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 1 AND a.""id2"" = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 1, '01', '011'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '011')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 1 AND a.""id2"" = '01')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new tbioudb03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 2, '02', '02'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(2, '02', '02')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 2 AND a.""id2"" = '02')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "01" }, new tbioudb03 { id1 = 2, id2 = "02", name = "02" }, new tbioudb03 { id1 = 3, id2 = "03", name = "03" }, new tbioudb03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 1, '01', '01'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 1 AND a.""id2"" = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '02'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 2 AND a.""id2"" = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '03'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 3 AND a.""id2"" = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '04'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 4 AND a.""id2"" = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb03>().IfExistsDoNothing().SetSource(new[] { new tbioudb03 { id1 = 1, id2 = "01", name = "001" }, new tbioudb03 { id1 = 2, id2 = "02", name = "002" }, new tbioudb03 { id1 = 3, id2 = "03", name = "003" }, new tbioudb03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb03""(""id1"", ""id2"", ""name"") SELECT 1, '01', '001'
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 1 AND a.""id2"" = '01')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', '002'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 2 AND a.""id2"" = '02')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', '003'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 3 AND a.""id2"" = '03')
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', '004'
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb03"" a
|
|
||||||
WHERE (a.""id1"" = 4 AND a.""id2"" = '04')
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
var lst = fsql.Select<tbioudb03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id1).Count());
|
||||||
@ -359,83 +169,27 @@ UNION ALL
|
|||||||
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbioudb04>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 1, '01', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 1, '011', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '011', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new tbioudb04 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 2, '02', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(2, '02', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "01" }, new tbioudb04 { id = 2, name = "02" }, new tbioudb04 { id = 3, name = "03" }, new tbioudb04 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 1, '01', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime')), (2, '02', 0, datetime(current_timestamp,'localtime')), (3, '03', 0, datetime(current_timestamp,'localtime')), (4, '04', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '02', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '03', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '04', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(2, iou.ExecuteAffrows());
|
Assert.Equal(2, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbioudb04>().IfExistsDoNothing().SetSource(new[] { new tbioudb04 { id = 1, name = "001" }, new tbioudb04 { id = 2, name = "002" }, new tbioudb04 { id = 3, name = "003" }, new tbioudb04 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"INSERT INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") SELECT 1, '001', 0, datetime(current_timestamp,'localtime')
|
Assert.Equal(@"INSERT OR IGNORE INTO ""tbioudb04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '001', 0, datetime(current_timestamp,'localtime')), (2, '002', 0, datetime(current_timestamp,'localtime')), (3, '003', 0, datetime(current_timestamp,'localtime')), (4, '004', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 1)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 2, '002', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 2)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 3, '003', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 3)
|
|
||||||
limit 0,1)
|
|
||||||
UNION ALL
|
|
||||||
SELECT 4, '004', 0, datetime(current_timestamp,'localtime')
|
|
||||||
WHERE NOT EXISTS(SELECT 1
|
|
||||||
FROM ""tbioudb04"" a
|
|
||||||
WHERE (a.""id"" = 4)
|
|
||||||
limit 0,1)", sql);
|
|
||||||
Assert.Equal(0, iou.ExecuteAffrows());
|
Assert.Equal(0, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbioudb04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "0" + a.id).Count());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -16,27 +16,27 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
fsql.Delete<tbiou01>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou01>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
var iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(1)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(1)", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 1 });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(1)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(1)", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 2 });
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new tbiou01 { id = 2 });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(2)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(2)", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(1), (2), (3), (4)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(1), (2), (3), (4)", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
iou = fsql.InsertOrUpdate<tbiou01>().SetSource(new[] { new tbiou01 { id = 1 }, new tbiou01 { id = 2 }, new tbiou01 { id = 3 }, new tbiou01 { id = 4 } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou01""(""id"") VALUES(1), (2), (3), (4)", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou01""(""id"") VALUES(1), (2), (3), (4)", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
}
|
}
|
||||||
class tbiou01
|
class tbiou01
|
||||||
@ -50,27 +50,27 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
fsql.Delete<tbiou02>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou02>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '01')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '01')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '011')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '011')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new tbiou02 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(2, '02')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(2, '02')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "01" }, new tbiou02 { id = 2, name = "02" }, new tbiou02 { id = 3, name = "03" }, new tbiou02 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "01" }, new tbiou02 { id = 2, name = "02" }, new tbiou02 { id = 3, name = "03" }, new tbiou02 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "001" }, new tbiou02 { id = 2, name = "002" }, new tbiou02 { id = 3, name = "003" }, new tbiou02 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbiou02>().SetSource(new[] { new tbiou02 { id = 1, name = "001" }, new tbiou02 { id = 2, name = "002" }, new tbiou02 { id = 3, name = "003" }, new tbiou02 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou02""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbiou02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbiou02>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
@ -87,27 +87,27 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
fsql.Delete<tbiou022>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou022>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '01')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '01')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '011')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '011')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new tbiou022 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(2, '02')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(2, '02')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "01" }, new tbiou022 { id = 2, name = "02" }, new tbiou022 { id = 3, name = "03" }, new tbiou022 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "01" }, new tbiou022 { id = 2, name = "02" }, new tbiou022 { id = 3, name = "03" }, new tbiou022 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '01'), (2, '02'), (3, '03'), (4, '04')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "001" }, new tbiou022 { id = 2, name = "002" }, new tbiou022 { id = 3, name = "003" }, new tbiou022 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "001" }, new tbiou022 { id = 2, name = "002" }, new tbiou022 { id = 3, name = "003" }, new tbiou022 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '001'), (2, '002'), (3, '003'), (4, '004')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbiou022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbiou022>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
@ -141,7 +141,7 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
//--no primary and yes
|
//--no primary and yes
|
||||||
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "100001" }, new tbiou022 { name = "00001" }, new tbiou022 { id = 2, name = "100002" }, new tbiou022 { name = "00002" }, new tbiou022 { id = 3, name = "100003" }, new tbiou022 { name = "00003" }, new tbiou022 { id = 4, name = "100004" }, new tbiou022 { name = "00004" } });
|
iou = fsql.InsertOrUpdate<tbiou022>().SetSource(new[] { new tbiou022 { id = 1, name = "100001" }, new tbiou022 { name = "00001" }, new tbiou022 { id = 2, name = "100002" }, new tbiou022 { name = "00002" }, new tbiou022 { id = 3, name = "100003" }, new tbiou022 { name = "00003" }, new tbiou022 { id = 4, name = "100004" }, new tbiou022 { name = "00004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou022""(""id"", ""name"") VALUES(1, '100001'), (2, '100002'), (3, '100003'), (4, '100004')
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -163,27 +163,27 @@ INSERT INTO ""tbiou022""(""name"") VALUES('00001'), ('00002'), ('00003'), ('0000
|
|||||||
fsql.Delete<tbiou03>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou03>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "01" });
|
var iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "011" });
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 1, id2 = "01", name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '011')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '011')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 2, id2 = "02", name = "02" });
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new tbiou03 { id1 = 2, id2 = "02", name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(2, '02', '02')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(2, '02', '02')", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "01" }, new tbiou03 { id1 = 2, id2 = "02", name = "02" }, new tbiou03 { id1 = 3, id2 = "03", name = "03" }, new tbiou03 { id1 = 4, id2 = "04", name = "04" } });
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "01" }, new tbiou03 { id1 = 2, id2 = "02", name = "02" }, new tbiou03 { id1 = 3, id2 = "03", name = "03" }, new tbiou03 { id1 = 4, id2 = "04", name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '01'), (2, '02', '02'), (3, '03', '03'), (4, '04', '04')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "001" }, new tbiou03 { id1 = 2, id2 = "02", name = "002" }, new tbiou03 { id1 = 3, id2 = "03", name = "003" }, new tbiou03 { id1 = 4, id2 = "04", name = "004" } });
|
iou = fsql.InsertOrUpdate<tbiou03>().SetSource(new[] { new tbiou03 { id1 = 1, id2 = "01", name = "001" }, new tbiou03 { id1 = 2, id2 = "02", name = "002" }, new tbiou03 { id1 = 3, id2 = "03", name = "003" }, new tbiou03 { id1 = 4, id2 = "04", name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou03""(""id1"", ""id2"", ""name"") VALUES(1, '01', '001'), (2, '02', '002'), (3, '03', '003'), (4, '04', '004')", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbiou03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
var lst = fsql.Select<tbiou03>().Where(a => a.id1 == 1 && a.id2 == "01" || a.id1 == 2 && a.id2 == "02" || a.id1 == 3 && a.id2 == "03" || a.id1 == 4 && a.id2 == "04").ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id1).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id1).Count());
|
||||||
@ -203,27 +203,27 @@ INSERT INTO ""tbiou022""(""name"") VALUES('00001'), ('00002'), ('00003'), ('0000
|
|||||||
fsql.Delete<tbiou04>().Where("1=1").ExecuteAffrows();
|
fsql.Delete<tbiou04>().Where("1=1").ExecuteAffrows();
|
||||||
var iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "01" });
|
var iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "01" });
|
||||||
var sql = iou.ToSql();
|
var sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "011" });
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 1, name = "011" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '011', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '011', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 2, name = "02" });
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new tbiou04 { id = 2, name = "02" });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(2, '02', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(2, '02', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(1, iou.ExecuteAffrows());
|
Assert.Equal(1, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "01" }, new tbiou04 { id = 2, name = "02" }, new tbiou04 { id = 3, name = "03" }, new tbiou04 { id = 4, name = "04" } });
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "01" }, new tbiou04 { id = 2, name = "02" }, new tbiou04 { id = 3, name = "03" }, new tbiou04 { id = 4, name = "04" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime')), (2, '02', 0, datetime(current_timestamp,'localtime')), (3, '03', 0, datetime(current_timestamp,'localtime')), (4, '04', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '01', 0, datetime(current_timestamp,'localtime')), (2, '02', 0, datetime(current_timestamp,'localtime')), (3, '03', 0, datetime(current_timestamp,'localtime')), (4, '04', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
|
|
||||||
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "001" }, new tbiou04 { id = 2, name = "002" }, new tbiou04 { id = 3, name = "003" }, new tbiou04 { id = 4, name = "004" } });
|
iou = fsql.InsertOrUpdate<tbiou04>().SetSource(new[] { new tbiou04 { id = 1, name = "001" }, new tbiou04 { id = 2, name = "002" }, new tbiou04 { id = 3, name = "003" }, new tbiou04 { id = 4, name = "004" } });
|
||||||
sql = iou.ToSql();
|
sql = iou.ToSql();
|
||||||
Assert.Equal(@"REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '001', 0, datetime(current_timestamp,'localtime')), (2, '002', 0, datetime(current_timestamp,'localtime')), (3, '003', 0, datetime(current_timestamp,'localtime')), (4, '004', 0, datetime(current_timestamp,'localtime'))", sql);
|
Assert.Equal(@"INSERT OR REPLACE INTO ""tbiou04""(""id"", ""name"", ""version"", ""CreateTime"") VALUES(1, '001', 0, datetime(current_timestamp,'localtime')), (2, '002', 0, datetime(current_timestamp,'localtime')), (3, '003', 0, datetime(current_timestamp,'localtime')), (4, '004', 0, datetime(current_timestamp,'localtime'))", sql);
|
||||||
Assert.Equal(4, iou.ExecuteAffrows());
|
Assert.Equal(4, iou.ExecuteAffrows());
|
||||||
var lst = fsql.Select<tbiou04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
var lst = fsql.Select<tbiou04>().Where(a => new[] { 1, 2, 3, 4 }.Contains(a.id)).ToList();
|
||||||
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
Assert.Equal(4, lst.Where(a => a.name == "00" + a.id).Count());
|
||||||
|
@ -29,7 +29,8 @@ namespace FreeSql
|
|||||||
break;
|
break;
|
||||||
case "SqlConnection":
|
case "SqlConnection":
|
||||||
providerType = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServer")?.MakeGenericType(connType);
|
providerType = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServer")?.MakeGenericType(connType);
|
||||||
if (providerType == null) throw new Exception(CoreStrings.Missing_FreeSqlProvider_Package("SqlServer"));
|
if (providerType == null) providerType = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServerForSystem")?.MakeGenericType(connType);
|
||||||
|
if (providerType == null) throw new Exception(CoreStrings.Missing_FreeSqlProvider_Package("SqlServer/SqlServerForSystem"));
|
||||||
break;
|
break;
|
||||||
case "NpgsqlConnection":
|
case "NpgsqlConnection":
|
||||||
providerType = Type.GetType("FreeSql.PostgreSQL.PostgreSQLProvider`1,FreeSql.Provider.PostgreSQL")?.MakeGenericType(connType);
|
providerType = Type.GetType("FreeSql.PostgreSQL.PostgreSQLProvider`1,FreeSql.Provider.PostgreSQL")?.MakeGenericType(connType);
|
||||||
@ -42,6 +43,7 @@ namespace FreeSql
|
|||||||
case "SQLiteConnection":
|
case "SQLiteConnection":
|
||||||
case "SqliteConnection":
|
case "SqliteConnection":
|
||||||
providerType = Type.GetType("FreeSql.Sqlite.SqliteProvider`1,FreeSql.Provider.Sqlite")?.MakeGenericType(connType);
|
providerType = Type.GetType("FreeSql.Sqlite.SqliteProvider`1,FreeSql.Provider.Sqlite")?.MakeGenericType(connType);
|
||||||
|
if (providerType == null) providerType = Type.GetType("FreeSql.Sqlite.SqliteProvider`1,FreeSql.Provider.SqliteCore")?.MakeGenericType(connType); //Microsoft.Data.Sqlite.Core.dll
|
||||||
if (providerType == null) throw new Exception(CoreStrings.Missing_FreeSqlProvider_Package("Sqlite/SqliteCore"));
|
if (providerType == null) throw new Exception(CoreStrings.Missing_FreeSqlProvider_Package("Sqlite/SqliteCore"));
|
||||||
break;
|
break;
|
||||||
case "DmConnection":
|
case "DmConnection":
|
||||||
|
@ -733,6 +733,7 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
|
|||||||
}
|
}
|
||||||
|
|
||||||
var sql1ctePath = "";
|
var sql1ctePath = "";
|
||||||
|
string wct2ctePath = null;
|
||||||
if (pathSelector != null)
|
if (pathSelector != null)
|
||||||
{
|
{
|
||||||
select._tables[0].Parameter = pathSelector?.Parameters[0];
|
select._tables[0].Parameter = pathSelector?.Parameters[0];
|
||||||
@ -751,6 +752,13 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
|
|||||||
case DataType.ClickHouse:
|
case DataType.ClickHouse:
|
||||||
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, Expression.Call(typeof(Convert).GetMethod("ToString", new Type[] { typeof(string) }), pathSelector?.Body), select._diymemexpWithTempQuery, null, null);
|
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, Expression.Call(typeof(Convert).GetMethod("ToString", new Type[] { typeof(string) }), pathSelector?.Body), select._diymemexpWithTempQuery, null, null);
|
||||||
break;
|
break;
|
||||||
|
case DataType.MySql:
|
||||||
|
case DataType.OdbcMySql:
|
||||||
|
case DataType.CustomMySql:
|
||||||
|
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
|
||||||
|
sql1ctePath = $"CAST({sql1ctePath} as char(2000))";
|
||||||
|
wct2ctePath = sql1ctePath;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
|
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
|
||||||
break;
|
break;
|
||||||
@ -770,7 +778,8 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
|
|||||||
if (pathSelector != null)
|
if (pathSelector != null)
|
||||||
{
|
{
|
||||||
select._tables[0].Parameter = pathSelector?.Parameters[0];
|
select._tables[0].Parameter = pathSelector?.Parameters[0];
|
||||||
var wct2ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
|
if (wct2ctePath == null)
|
||||||
|
wct2ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
|
||||||
sql2ctePath = select._commonUtils.StringConcat(
|
sql2ctePath = select._commonUtils.StringConcat(
|
||||||
new string[] {
|
new string[] {
|
||||||
up == false ? "wct1.cte_path" : wct2ctePath,
|
up == false ? "wct1.cte_path" : wct2ctePath,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.1;netstandard2.0;net451;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.1;netstandard2.0;net451;net45;net40</TargetFrameworks>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1445,6 +1445,14 @@
|
|||||||
<param name="providerType">提供者的类型,一般不需要指定,如果一直提示“缺少 FreeSql 数据库实现包:FreeSql.Provider.MySql.dll,可前往 nuget 下载”的错误,说明反射获取不到类型,此时该参数可排上用场<para></para>例如:typeof(FreeSql.SqlServer.SqlServerProvider<>)</param>
|
<param name="providerType">提供者的类型,一般不需要指定,如果一直提示“缺少 FreeSql 数据库实现包:FreeSql.Provider.MySql.dll,可前往 nuget 下载”的错误,说明反射获取不到类型,此时该参数可排上用场<para></para>例如:typeof(FreeSql.SqlServer.SqlServerProvider<>)</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:FreeSql.FreeSqlBuilder.UseCustomTableEntityCacheFactory(System.Func{System.Collections.Concurrent.ConcurrentDictionary{FreeSql.DataType,System.Collections.Concurrent.ConcurrentDictionary{System.Type,FreeSql.Internal.Model.TableInfo}}})">
|
||||||
|
<summary>
|
||||||
|
用于指定自定义实现TableEntiy 的缓存集合
|
||||||
|
解决多实例下相同类型映射到不同表的问题
|
||||||
|
</summary>
|
||||||
|
<param name="factory"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:FreeSql.FreeSqlBuilder.UseAdoConnectionPool(System.Boolean)">
|
<member name="M:FreeSql.FreeSqlBuilder.UseAdoConnectionPool(System.Boolean)">
|
||||||
<summary>
|
<summary>
|
||||||
使用原始连接池(ado.net、odbc、oledb)<para></para>
|
使用原始连接池(ado.net、odbc、oledb)<para></para>
|
||||||
@ -1543,7 +1551,7 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.FreeSqlBuilder.UseMappingPriority(FreeSql.Internal.MappingPriorityType,FreeSql.Internal.MappingPriorityType,FreeSql.Internal.MappingPriorityType)">
|
<member name="M:FreeSql.FreeSqlBuilder.UseMappingPriority(FreeSql.Internal.MappingPriorityType,FreeSql.Internal.MappingPriorityType,FreeSql.Internal.MappingPriorityType)">
|
||||||
<summary>
|
<summary>
|
||||||
指定映射优先级<para></para>
|
指定映射优先级(从小到大)<para></para>
|
||||||
例如表名:实体类名 < Aop < FluentApi < Attribute < AsTable<para></para>
|
例如表名:实体类名 < Aop < FluentApi < Attribute < AsTable<para></para>
|
||||||
事件 Aop -------> fsql.Aop.ConfigEntity/fsql.Aop.ConfigEntityProperty<para></para>
|
事件 Aop -------> fsql.Aop.ConfigEntity/fsql.Aop.ConfigEntityProperty<para></para>
|
||||||
方法 FluentApi -> fsql.CodeFirst.ConfigEntity/fsql.CodeFirst.Entity<para></para>
|
方法 FluentApi -> fsql.CodeFirst.ConfigEntity/fsql.CodeFirst.Entity<para></para>
|
||||||
@ -3404,11 +3412,12 @@
|
|||||||
<param name="name">零个或多个过滤器名字</param>
|
<param name="name">零个或多个过滤器名字</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.IUpdateJoin`2.AsTable(System.String)">
|
<member name="M:FreeSql.IUpdateJoin`2.AsTable(System.String,System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
设置表名
|
设置表名
|
||||||
</summary>
|
</summary>
|
||||||
<param name="tableName"></param>
|
<param name="tableName"></param>
|
||||||
|
<param name="joinTableName"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.IUpdateJoin`2.ToSql">
|
<member name="M:FreeSql.IUpdateJoin`2.ToSql">
|
||||||
@ -4060,6 +4069,11 @@
|
|||||||
DataReader 对应的 Index 位置
|
DataReader 对应的 Index 位置
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:FreeSql.Aop.AuditDataReaderEventArgs.Property">
|
||||||
|
<summary>
|
||||||
|
DataReader 对应的 PropertyInfo
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:FreeSql.Aop.AuditDataReaderEventArgs.Value">
|
<member name="P:FreeSql.Aop.AuditDataReaderEventArgs.Value">
|
||||||
<summary>
|
<summary>
|
||||||
获取 Index 对应的值,也可以设置拦截的新值
|
获取 Index 对应的值,也可以设置拦截的新值
|
||||||
@ -5002,6 +5016,11 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="F:FreeSql.Internal.Utils.ChacheTableEntityFactory">
|
||||||
|
<summary>
|
||||||
|
用于解决多实例情况下的静态集合缓存问题
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:FreeSql.CoreStrings">
|
<member name="T:FreeSql.CoreStrings">
|
||||||
<summary>
|
<summary>
|
||||||
<para>
|
<para>
|
||||||
|
@ -11,6 +11,7 @@ using System.Linq.Expressions;
|
|||||||
using System.Runtime;
|
using System.Runtime;
|
||||||
using FreeSql.Internal.Model.Interface;
|
using FreeSql.Internal.Model.Interface;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using FreeSql.Internal.Model;
|
||||||
|
|
||||||
namespace FreeSql
|
namespace FreeSql
|
||||||
{
|
{
|
||||||
@ -50,6 +51,18 @@ namespace FreeSql
|
|||||||
_providerType = providerType;
|
_providerType = providerType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用于指定自定义实现TableEntiy 的缓存集合
|
||||||
|
/// 解决多实例下相同类型映射到不同表的问题
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="factory"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public FreeSqlBuilder UseCustomTableEntityCacheFactory(Func<ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>> factory)
|
||||||
|
{
|
||||||
|
Utils.ChacheTableEntityFactory = factory;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 使用原始连接池(ado.net、odbc、oledb)<para></para>
|
/// 使用原始连接池(ado.net、odbc、oledb)<para></para>
|
||||||
/// 默认:false<para></para>
|
/// 默认:false<para></para>
|
||||||
@ -63,7 +76,7 @@ namespace FreeSql
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public FreeSqlBuilder UseAdoConnectionPool(bool value)
|
public FreeSqlBuilder UseAdoConnectionPool(bool value)
|
||||||
{
|
{
|
||||||
_isAdoConnectionPool = value ;
|
_isAdoConnectionPool = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -194,7 +207,7 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指定映射优先级<para></para>
|
/// 指定映射优先级(从小到大)<para></para>
|
||||||
/// 例如表名:实体类名 < Aop < FluentApi < Attribute < AsTable<para></para>
|
/// 例如表名:实体类名 < Aop < FluentApi < Attribute < AsTable<para></para>
|
||||||
/// 事件 Aop -------> fsql.Aop.ConfigEntity/fsql.Aop.ConfigEntityProperty<para></para>
|
/// 事件 Aop -------> fsql.Aop.ConfigEntity/fsql.Aop.ConfigEntityProperty<para></para>
|
||||||
/// 方法 FluentApi -> fsql.CodeFirst.ConfigEntity/fsql.CodeFirst.Entity<para></para>
|
/// 方法 FluentApi -> fsql.CodeFirst.ConfigEntity/fsql.CodeFirst.Entity<para></para>
|
||||||
@ -577,7 +590,8 @@ namespace FreeSql
|
|||||||
{
|
{
|
||||||
FreeSql.Internal.Utils.GetDataReaderValueBlockExpressionSwitchTypeFullName.Add((LabelTarget returnTarget, Expression valueExp, Type type2) =>
|
FreeSql.Internal.Utils.GetDataReaderValueBlockExpressionSwitchTypeFullName.Add((LabelTarget returnTarget, Expression valueExp, Type type2) =>
|
||||||
{
|
{
|
||||||
if (FreeSql.Internal.Utils.TypeHandlers.TryGetValue(type2, out var typeHandler)) {
|
if (FreeSql.Internal.Utils.TypeHandlers.TryGetValue(type2, out var typeHandler))
|
||||||
|
{
|
||||||
var valueExpRet = Expression.Call(
|
var valueExpRet = Expression.Call(
|
||||||
Expression.Constant(typeHandler, typeof(ITypeHandler)),
|
Expression.Constant(typeHandler, typeof(ITypeHandler)),
|
||||||
typeof(ITypeHandler).GetMethod(nameof(typeHandler.Deserialize)),
|
typeof(ITypeHandler).GetMethod(nameof(typeHandler.Deserialize)),
|
||||||
@ -598,9 +612,10 @@ namespace FreeSql
|
|||||||
{
|
{
|
||||||
if (e.Property.PropertyType == typeHandler.Type)
|
if (e.Property.PropertyType == typeHandler.Type)
|
||||||
{
|
{
|
||||||
if (_dicTypeHandlerTypes.ContainsKey(e.Property.PropertyType) == false &&
|
if (_dicTypeHandlerTypes.ContainsKey(e.Property.PropertyType)) return;
|
||||||
|
if (e.Property.PropertyType.NullableTypeOrThis() != typeof(DateTime) &&
|
||||||
FreeSql.Internal.Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(e.Property.PropertyType))
|
FreeSql.Internal.Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(e.Property.PropertyType))
|
||||||
return; //基础类型无效
|
return; //基础类型无效,DateTime 除外
|
||||||
|
|
||||||
if (_dicTypeHandlerTypes.TryAdd(e.Property.PropertyType, true))
|
if (_dicTypeHandlerTypes.TryAdd(e.Property.PropertyType, true))
|
||||||
{
|
{
|
||||||
|
@ -106,8 +106,9 @@ namespace FreeSql
|
|||||||
/// 设置表名
|
/// 设置表名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tableName"></param>
|
/// <param name="tableName"></param>
|
||||||
|
/// <param name="joinTableName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
IUpdateJoin<T1, T2> AsTable(string tableName);
|
IUpdateJoin<T1, T2> AsTable(string tableName, string joinTableName);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 返回即将执行的SQL语句
|
/// 返回即将执行的SQL语句
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -360,10 +360,11 @@ namespace FreeSql.Aop
|
|||||||
#region AuditDataReader
|
#region AuditDataReader
|
||||||
public class AuditDataReaderEventArgs : EventArgs
|
public class AuditDataReaderEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public AuditDataReaderEventArgs(DbDataReader dataReader, int index)
|
public AuditDataReaderEventArgs(DbDataReader dataReader, int index, PropertyInfo property)
|
||||||
{
|
{
|
||||||
this.DataReader = dataReader;
|
this.DataReader = dataReader;
|
||||||
this.Index = index;
|
this.Index = index;
|
||||||
|
this.Property = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -375,6 +376,10 @@ namespace FreeSql.Aop
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// DataReader 对应的 PropertyInfo
|
||||||
|
/// </summary>
|
||||||
|
public PropertyInfo Property { get; }
|
||||||
|
/// <summary>
|
||||||
/// 获取 Index 对应的值,也可以设置拦截的新值
|
/// 获取 Index 对应的值,也可以设置拦截的新值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object Value
|
public object Value
|
||||||
|
@ -570,7 +570,7 @@ namespace FreeSql.Internal
|
|||||||
return Utils.GetDataReaderValue(parent.Property.PropertyType, null);
|
return Utils.GetDataReaderValue(parent.Property.PropertyType, null);
|
||||||
return Utils.GetDataReaderValue(parent.CsType, null);
|
return Utils.GetDataReaderValue(parent.CsType, null);
|
||||||
}
|
}
|
||||||
object objval = Utils.InternalDataReaderGetValue(_common, dr, ++index); // dr.GetValue(++index);
|
object objval = Utils.InternalDataReaderGetValue(_common, dr, ++index, parent.Property); // dr.GetValue(++index);
|
||||||
if (dbValue != null) dbValue.DbValue = objval == DBNull.Value ? null : objval;
|
if (dbValue != null) dbValue.DbValue = objval == DBNull.Value ? null : objval;
|
||||||
if (parent.CsType != parent.MapType)
|
if (parent.CsType != parent.MapType)
|
||||||
objval = Utils.GetDataReaderValue(parent.MapType, objval);
|
objval = Utils.GetDataReaderValue(parent.MapType, objval);
|
||||||
|
@ -40,7 +40,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
#else
|
#else
|
||||||
public List<Func<object, CancellationToken, Task>> _includeToListAsync = new List<Func<object, CancellationToken, Task>>();
|
public List<Func<object, CancellationToken, Task>> _includeToListAsync = new List<Func<object, CancellationToken, Task>>();
|
||||||
#endif
|
#endif
|
||||||
public Dictionary<string, MemberExpression[]> _includeInfo = new Dictionary<string, MemberExpression[]>();
|
public Dictionary<string, NativeTuple<MemberExpression[], TableRef>> _includeInfo = new Dictionary<string, NativeTuple<MemberExpression[], TableRef>>();
|
||||||
public bool _distinct;
|
public bool _distinct;
|
||||||
public Expression _selectExpression;
|
public Expression _selectExpression;
|
||||||
public List<GlobalFilter.Item> _whereGlobalFilter;
|
public List<GlobalFilter.Item> _whereGlobalFilter;
|
||||||
@ -672,9 +672,12 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
_join.Append(" \r\n").Append(sql);
|
_join.Append(" \r\n").Append(sql);
|
||||||
|
|
||||||
//fsql.Select<User1, UserGroup>().RawJoin("FULL JOIN UserGroup b ON b.id = a.GroupId").ToSql((a, b) => new { user = a, group = b });
|
//fsql.Select<User1, UserGroup>().RawJoin("FULL JOIN UserGroup b ON b.id = a.GroupId").ToSql((a, b) => new { user = a, group = b });
|
||||||
foreach (var tb in _tables)
|
for (var a = 1; a < _tables.Count; a++)
|
||||||
|
{
|
||||||
|
var tb = _tables[a];
|
||||||
if (sql.Contains($" {tb.Table.DbName} ") || sql.Contains($" {_commonUtils.QuoteSqlName(tb.Table.DbName)} "))
|
if (sql.Contains($" {tb.Table.DbName} ") || sql.Contains($" {_commonUtils.QuoteSqlName(tb.Table.DbName)} "))
|
||||||
tb.Type = SelectTableInfoType.RawJoin;
|
tb.Type = SelectTableInfoType.RawJoin;
|
||||||
|
}
|
||||||
return this as TSelect;
|
return this as TSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +600,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
var name = dr.GetName(a);
|
var name = dr.GetName(a);
|
||||||
//expando[name] = row2.GetValue(a);
|
//expando[name] = row2.GetValue(a);
|
||||||
if (expandodic.ContainsKey(name)) continue;
|
if (expandodic.ContainsKey(name)) continue;
|
||||||
expandodic.Add(name, Utils.InternalDataReaderGetValue(_commonUtils, dr, a));
|
expandodic.Add(name, Utils.InternalDataReaderGetValue(_commonUtils, dr, a, null));
|
||||||
}
|
}
|
||||||
//expando = expandodic;
|
//expando = expandodic;
|
||||||
return (T1)((object)expandodic);
|
return (T1)((object)expandodic);
|
||||||
@ -682,8 +682,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
var propGetSetMethod = prop.GetSetMethod(true);
|
var propGetSetMethod = prop.GetSetMethod(true);
|
||||||
Expression readExpAssign = null; //加速缓存
|
Expression readExpAssign = null; //加速缓存
|
||||||
if (prop.PropertyType.IsArray) readExpAssign = Expression.New(Utils.RowInfo.Constructor,
|
if (prop.PropertyType.IsArray) readExpAssign = Expression.New(Utils.RowInfo.Constructor,
|
||||||
Utils.GetDataReaderValueBlockExpression(prop.PropertyType, Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, dataIndexExp })),
|
Utils.GetDataReaderValueBlockExpression(prop.PropertyType, Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, dataIndexExp, Expression.Constant(prop) })),
|
||||||
//Expression.Call(Utils.MethodGetDataReaderValue, new Expression[] { Expression.Constant(prop.PropertyType), Expression.Call(rowExp, Utils.MethodDataReaderGetValue, dataIndexExp) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
@ -692,8 +691,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
if (proptypeGeneric.IsNullableType()) proptypeGeneric = proptypeGeneric.GetGenericArguments().First();
|
if (proptypeGeneric.IsNullableType()) proptypeGeneric = proptypeGeneric.GetGenericArguments().First();
|
||||||
if (proptypeGeneric.IsEnum ||
|
if (proptypeGeneric.IsEnum ||
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(proptypeGeneric)) readExpAssign = Expression.New(Utils.RowInfo.Constructor,
|
Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(proptypeGeneric)) readExpAssign = Expression.New(Utils.RowInfo.Constructor,
|
||||||
Utils.GetDataReaderValueBlockExpression(prop.PropertyType, Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, dataIndexExp })),
|
Utils.GetDataReaderValueBlockExpression(prop.PropertyType, Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, dataIndexExp, Expression.Constant(prop) })),
|
||||||
//Expression.Call(Utils.MethodGetDataReaderValue, new Expression[] { Expression.Constant(prop.PropertyType), Expression.Call(rowExp, Utils.MethodDataReaderGetValue, dataIndexExp) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
@ -739,7 +737,8 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
foreach (var col in tb.Table.Columns.Values)
|
foreach (var col in tb.Table.Columns.Values)
|
||||||
{
|
{
|
||||||
var drvalType = col.Attribute.MapType.NullableTypeOrThis();
|
var drvalType = col.Attribute.MapType.NullableTypeOrThis();
|
||||||
var propGetSetMethod = tb.Table.Properties[col.CsName].GetSetMethod(true);
|
var colprop = tb.Table.Properties[col.CsName];
|
||||||
|
var propGetSetMethod = colprop.GetSetMethod(true);
|
||||||
if (col.CsType == col.Attribute.MapType &&
|
if (col.CsType == col.Attribute.MapType &&
|
||||||
_orm.Aop.AuditDataReaderHandler == null &&
|
_orm.Aop.AuditDataReaderHandler == null &&
|
||||||
_dicMethodDataReaderGetValue.TryGetValue(col.Attribute.MapType.NullableTypeOrThis(), out var drGetValueMethod))
|
_dicMethodDataReaderGetValue.TryGetValue(col.Attribute.MapType.NullableTypeOrThis(), out var drGetValueMethod))
|
||||||
@ -755,7 +754,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
{
|
{
|
||||||
var drvalExpCatch = Utils.GetDataReaderValueBlockExpression(
|
var drvalExpCatch = Utils.GetDataReaderValueBlockExpression(
|
||||||
col.CsType,
|
col.CsType,
|
||||||
Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, Expression.Constant(colidx) })
|
Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, Expression.Constant(colidx), Expression.Constant(colprop) })
|
||||||
);
|
);
|
||||||
blockExp.Add(Expression.TryCatch(
|
blockExp.Add(Expression.TryCatch(
|
||||||
Expression.Call(retExp, propGetSetMethod, drvalExp),
|
Expression.Call(retExp, propGetSetMethod, drvalExp),
|
||||||
@ -780,7 +779,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
{
|
{
|
||||||
var drvalExp = Utils.GetDataReaderValueBlockExpression(
|
var drvalExp = Utils.GetDataReaderValueBlockExpression(
|
||||||
col.CsType,
|
col.CsType,
|
||||||
Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, Expression.Constant(colidx) })
|
Expression.Call(Utils.MethodDataReaderGetValue, new Expression[] { Expression.Constant(_commonUtils), rowExp, Expression.Constant(colidx), Expression.Constant(colprop) })
|
||||||
);
|
);
|
||||||
blockExp.Add(Expression.Call(retExp, propGetSetMethod, Expression.Convert(drvalExp, col.CsType)));
|
blockExp.Add(Expression.Call(retExp, propGetSetMethod, Expression.Convert(drvalExp, col.CsType)));
|
||||||
}
|
}
|
||||||
|
@ -287,6 +287,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
public Dictionary<string, IncludeManyNewInit> Childs { get; } = new Dictionary<string, IncludeManyNewInit>();
|
public Dictionary<string, IncludeManyNewInit> Childs { get; } = new Dictionary<string, IncludeManyNewInit>();
|
||||||
public Expression CurrentExpression { get; }
|
public Expression CurrentExpression { get; }
|
||||||
public bool IsOutputPrimary { get; set; }
|
public bool IsOutputPrimary { get; set; }
|
||||||
|
public List<ColumnInfo> OutputColumns { get; } = new List<ColumnInfo>();
|
||||||
public IncludeManyNewInit(TableInfo table, Expression currentExpression)
|
public IncludeManyNewInit(TableInfo table, Expression currentExpression)
|
||||||
{
|
{
|
||||||
this.Table = table;
|
this.Table = table;
|
||||||
@ -313,20 +314,26 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
{
|
{
|
||||||
var curIncNewInit = incNewInit;
|
var curIncNewInit = incNewInit;
|
||||||
Expression curParmExp = parmExp;
|
Expression curParmExp = parmExp;
|
||||||
for (var a = 0; a < inc.Value.Length - 1; a++)
|
for (var a = 0; a < inc.Value.Item1.Length - 1; a++)
|
||||||
{
|
{
|
||||||
curParmExp = Expression.MakeMemberAccess(parmExp, inc.Value[a].Member);
|
curParmExp = Expression.MakeMemberAccess(parmExp, inc.Value.Item1[a].Member);
|
||||||
if (curIncNewInit.Childs.ContainsKey(inc.Value[a].Member.Name) == false)
|
if (curIncNewInit.Childs.ContainsKey(inc.Value.Item1[a].Member.Name) == false)
|
||||||
curIncNewInit.Childs.Add(inc.Value[a].Member.Name, curIncNewInit = new IncludeManyNewInit(_orm.CodeFirst.GetTableByEntity(inc.Value[a].Type), curParmExp));
|
curIncNewInit.Childs.Add(inc.Value.Item1[a].Member.Name, curIncNewInit = new IncludeManyNewInit(_orm.CodeFirst.GetTableByEntity(inc.Value.Item1[a].Type), curParmExp));
|
||||||
else
|
else
|
||||||
curIncNewInit = curIncNewInit.Childs[inc.Value[a].Member.Name];
|
curIncNewInit = curIncNewInit.Childs[inc.Value.Item1[a].Member.Name];
|
||||||
}
|
}
|
||||||
curIncNewInit.IsOutputPrimary = true;
|
curIncNewInit.IsOutputPrimary = true;
|
||||||
|
var outcols = inc.Value.Item2.Columns.Where(a => a.Attribute.IsPrimary == false).ToArray();
|
||||||
|
if (outcols.Any()) curIncNewInit.OutputColumns.AddRange(outcols);
|
||||||
}
|
}
|
||||||
MemberInitExpression GetIncludeManyNewInitExpression(IncludeManyNewInit imni)
|
MemberInitExpression GetIncludeManyNewInitExpression(IncludeManyNewInit imni)
|
||||||
{
|
{
|
||||||
var bindings = new List<MemberBinding>();
|
var bindings = new List<MemberBinding>();
|
||||||
if (imni.IsOutputPrimary) bindings.AddRange(imni.Table.Primarys.Select(a => Expression.Bind(imni.Table.Properties[a.CsName], Expression.MakeMemberAccess(imni.CurrentExpression, imni.Table.Properties[a.CsName]))));
|
if (imni.IsOutputPrimary)
|
||||||
|
{
|
||||||
|
bindings.AddRange(imni.Table.Primarys.Select(a => Expression.Bind(imni.Table.Properties[a.CsName], Expression.MakeMemberAccess(imni.CurrentExpression, imni.Table.Properties[a.CsName]))));
|
||||||
|
if (imni.OutputColumns.Any()) bindings.AddRange(imni.OutputColumns.Select(a => Expression.Bind(imni.Table.Properties[a.CsName], Expression.MakeMemberAccess(imni.CurrentExpression, imni.Table.Properties[a.CsName]))));
|
||||||
|
}
|
||||||
if (imni.Childs.Any()) bindings.AddRange(imni.Childs.Select(a => Expression.Bind(imni.Table.Properties[a.Key], GetIncludeManyNewInitExpression(a.Value))));
|
if (imni.Childs.Any()) bindings.AddRange(imni.Childs.Select(a => Expression.Bind(imni.Table.Properties[a.Key], GetIncludeManyNewInitExpression(a.Value))));
|
||||||
var pgarrayToManys = imni.Table.GetAllTableRef().Select(tr =>
|
var pgarrayToManys = imni.Table.GetAllTableRef().Select(tr =>
|
||||||
{
|
{
|
||||||
@ -1514,7 +1521,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
for (var a = 0; a < members.Count; a++) includeValue[a] = members[a];
|
for (var a = 0; a < members.Count; a++) includeValue[a] = members[a];
|
||||||
includeValue[includeValue.Length - 1] = expBody as MemberExpression;
|
includeValue[includeValue.Length - 1] = expBody as MemberExpression;
|
||||||
var includeKey = $"{string.Join(".", includeValue.Select(a => a.Member.Name))}";
|
var includeKey = $"{string.Join(".", includeValue.Select(a => a.Member.Name))}";
|
||||||
if (_includeInfo.ContainsKey(includeKey) == false) _includeInfo.Add(includeKey, includeValue);
|
if (_includeInfo.ContainsKey(includeKey) == false) _includeInfo.Add(includeKey, NativeTuple.Create(includeValue, tbref));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1577,20 +1584,26 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
{
|
{
|
||||||
var curIncNewInit = incNewInit;
|
var curIncNewInit = incNewInit;
|
||||||
Expression curParmExp = parmExp;
|
Expression curParmExp = parmExp;
|
||||||
for (var a = 0; a < inc.Value.Length - 1; a++)
|
for (var a = 0; a < inc.Value.Item1.Length - 1; a++)
|
||||||
{
|
{
|
||||||
curParmExp = Expression.MakeMemberAccess(parmExp, inc.Value[a].Member);
|
curParmExp = Expression.MakeMemberAccess(parmExp, inc.Value.Item1[a].Member);
|
||||||
if (curIncNewInit.Childs.ContainsKey(inc.Value[a].Member.Name) == false)
|
if (curIncNewInit.Childs.ContainsKey(inc.Value.Item1[a].Member.Name) == false)
|
||||||
curIncNewInit.Childs.Add(inc.Value[a].Member.Name, curIncNewInit = new IncludeManyNewInit(_orm.CodeFirst.GetTableByEntity(inc.Value[a].Type), curParmExp));
|
curIncNewInit.Childs.Add(inc.Value.Item1[a].Member.Name, curIncNewInit = new IncludeManyNewInit(_orm.CodeFirst.GetTableByEntity(inc.Value.Item1[a].Type), curParmExp));
|
||||||
else
|
else
|
||||||
curIncNewInit = curIncNewInit.Childs[inc.Value[a].Member.Name];
|
curIncNewInit = curIncNewInit.Childs[inc.Value.Item1[a].Member.Name];
|
||||||
}
|
}
|
||||||
curIncNewInit.IsOutputPrimary = true;
|
curIncNewInit.IsOutputPrimary = true;
|
||||||
|
var outcols = inc.Value.Item2.Columns.Where(a => a.Attribute.IsPrimary == false).ToArray();
|
||||||
|
if (outcols.Any()) curIncNewInit.OutputColumns.AddRange(outcols);
|
||||||
}
|
}
|
||||||
MemberInitExpression GetIncludeManyNewInitExpression(IncludeManyNewInit imni)
|
MemberInitExpression GetIncludeManyNewInitExpression(IncludeManyNewInit imni)
|
||||||
{
|
{
|
||||||
var bindings = new List<MemberBinding>();
|
var bindings = new List<MemberBinding>();
|
||||||
if (imni.IsOutputPrimary) bindings.AddRange(imni.Table.Primarys.Select(a => Expression.Bind(imni.Table.Properties[a.CsName], Expression.MakeMemberAccess(imni.CurrentExpression, imni.Table.Properties[a.CsName]))));
|
if (imni.IsOutputPrimary)
|
||||||
|
{
|
||||||
|
bindings.AddRange(imni.Table.Primarys.Select(a => Expression.Bind(imni.Table.Properties[a.CsName], Expression.MakeMemberAccess(imni.CurrentExpression, imni.Table.Properties[a.CsName]))));
|
||||||
|
if (imni.OutputColumns.Any()) bindings.AddRange(imni.OutputColumns.Select(a => Expression.Bind(imni.Table.Properties[a.CsName], Expression.MakeMemberAccess(imni.CurrentExpression, imni.Table.Properties[a.CsName]))));
|
||||||
|
}
|
||||||
if (imni.Childs.Any()) bindings.AddRange(imni.Childs.Select(a => Expression.Bind(imni.Table.Properties[a.Key], GetIncludeManyNewInitExpression(a.Value))));
|
if (imni.Childs.Any()) bindings.AddRange(imni.Childs.Select(a => Expression.Bind(imni.Table.Properties[a.Key], GetIncludeManyNewInitExpression(a.Value))));
|
||||||
var pgarrayToManys = imni.Table.GetAllTableRef().Select(tr =>
|
var pgarrayToManys = imni.Table.GetAllTableRef().Select(tr =>
|
||||||
{
|
{
|
||||||
|
@ -98,9 +98,19 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region proxy IUpdate
|
#region proxy IUpdate
|
||||||
public IUpdateJoin<T1, T2> AsTable(string tableName)
|
public IUpdateJoin<T1, T2> AsTable(string tableName, string joinTableName)
|
||||||
{
|
{
|
||||||
_update.AsTable(tableName);
|
if (string.IsNullOrWhiteSpace(tableName) == false)
|
||||||
|
_update.AsTable(tableName);
|
||||||
|
if (string.IsNullOrWhiteSpace(joinTableName) == false)
|
||||||
|
{
|
||||||
|
_query2Provider._tableRules.Clear();
|
||||||
|
_query2Provider._tableRules.Add((t, old) =>
|
||||||
|
{
|
||||||
|
if (t == typeof(T2)) return joinTableName;
|
||||||
|
return old;
|
||||||
|
});
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public IUpdateJoin<T1, T2> WithConnection(DbConnection connection)
|
public IUpdateJoin<T1, T2> WithConnection(DbConnection connection)
|
||||||
|
@ -1216,6 +1216,24 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
if (_versionColumn != null && _versionColumn.Attribute.CanUpdate)
|
if (_versionColumn != null && _versionColumn.Attribute.CanUpdate)
|
||||||
{
|
{
|
||||||
var vcname = _commonUtils.QuoteSqlName(_versionColumn.Attribute.Name);
|
var vcname = _commonUtils.QuoteSqlName(_versionColumn.Attribute.Name);
|
||||||
|
var vcvalue = vcname;
|
||||||
|
if (string.IsNullOrWhiteSpace(_tableAlias) == false)
|
||||||
|
{
|
||||||
|
switch (_orm.Ado.DataType)
|
||||||
|
{
|
||||||
|
case DataType.PostgreSQL:
|
||||||
|
case DataType.OdbcPostgreSQL:
|
||||||
|
case DataType.CustomPostgreSQL:
|
||||||
|
case DataType.KingbaseES:
|
||||||
|
case DataType.OdbcKingbaseES:
|
||||||
|
case DataType.ShenTong:
|
||||||
|
vcvalue = $"{_tableAlias}.{vcname}"; //set name = b.name
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
vcname = vcvalue = $"{_tableAlias}.{vcname}"; //set a.name = b.name
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (_versionColumn.Attribute.MapType == typeof(byte[]))
|
if (_versionColumn.Attribute.MapType == typeof(byte[]))
|
||||||
{
|
{
|
||||||
_updateVersionValue = Utils.GuidToBytes(Guid.NewGuid());
|
_updateVersionValue = Utils.GuidToBytes(Guid.NewGuid());
|
||||||
@ -1227,7 +1245,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
sb.Append(", ").Append(vcname).Append(" = ").Append(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "uv", _versionColumn, _versionColumn.Attribute.MapType, _updateVersionValue));
|
sb.Append(", ").Append(vcname).Append(" = ").Append(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "uv", _versionColumn, _versionColumn.Attribute.MapType, _updateVersionValue));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sb.Append(", ").Append(vcname).Append(" = ").Append(_commonUtils.IsNull(vcname, 0)).Append(" + 1");
|
sb.Append(", ").Append(vcname).Append(" = ").Append(_commonUtils.IsNull(vcvalue, 0)).Append(" + 1");
|
||||||
}
|
}
|
||||||
ToSqlWhere(sb);
|
ToSqlWhere(sb);
|
||||||
_interceptSql?.Invoke(sb);
|
_interceptSql?.Invoke(sb);
|
||||||
|
@ -19,8 +19,12 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
public class Utils
|
public class Utils
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>> _cacheGetTableByEntity = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>();
|
/// 用于解决多实例情况下的静态集合缓存问题
|
||||||
|
/// </summary>
|
||||||
|
public static Func<ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>> ChacheTableEntityFactory = null;
|
||||||
|
private static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>> __cacheGetTableByEntity = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>();
|
||||||
|
public static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>> _cacheGetTableByEntity => ChacheTableEntityFactory?.Invoke() ?? __cacheGetTableByEntity;
|
||||||
internal static void RemoveTableByEntity(Type entity, CommonUtils common)
|
internal static void RemoveTableByEntity(Type entity, CommonUtils common)
|
||||||
{
|
{
|
||||||
if (entity.IsAnonymousType() ||
|
if (entity.IsAnonymousType() ||
|
||||||
@ -258,9 +262,14 @@ namespace FreeSql.Internal
|
|||||||
commonNow = $"{commonNow.TrimEnd('(', ')')}({timeLength})";
|
commonNow = $"{commonNow.TrimEnd('(', ')')}({timeLength})";
|
||||||
commonNowUtc = $"{commonNowUtc.TrimEnd('(', ')')}({timeLength})";
|
commonNowUtc = $"{commonNowUtc.TrimEnd('(', ')')}({timeLength})";
|
||||||
}
|
}
|
||||||
|
//https://github.com/dotnetcore/FreeSql/issues/1604 mysql 不支持默认值 utc_timestamp DDL
|
||||||
|
if (colattr.ServerTime == DateTimeKind.Local)
|
||||||
|
col.DbDefaultValue = commonNow;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
col.DbDefaultValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
col.DbDefaultValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
|
|
||||||
col.DbInsertValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
|
col.DbInsertValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
|
||||||
col.DbUpdateValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
|
col.DbUpdateValue = colattr.ServerTime == DateTimeKind.Local ? commonNow : commonNowUtc;
|
||||||
}
|
}
|
||||||
@ -500,10 +509,6 @@ namespace FreeSql.Internal
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
trytb.Indexes = indexesDict.Values.ToArray();
|
trytb.Indexes = indexesDict.Values.ToArray();
|
||||||
trytb.ColumnsByPosition = columnsList.Where(a => a.Attribute.Position > 0).OrderBy(a => a.Attribute.Position)
|
|
||||||
.Concat(columnsList.Where(a => a.Attribute.Position == 0))
|
|
||||||
.Concat(columnsList.Where(a => a.Attribute.Position < 0).OrderBy(a => a.Attribute.Position)).ToArray();
|
|
||||||
trytb.ColumnsByCanUpdateDbUpdateValue = columnsList.Where(a => a.Attribute.CanUpdate == true && string.IsNullOrEmpty(a.DbUpdateValue) == false).ToArray();
|
|
||||||
|
|
||||||
trytb.Primarys = trytb.Columns.Values.Where(a => a.Attribute.IsPrimary == true).ToArray();
|
trytb.Primarys = trytb.Columns.Values.Where(a => a.Attribute.IsPrimary == true).ToArray();
|
||||||
if (trytb.Primarys.Any() == false)
|
if (trytb.Primarys.Any() == false)
|
||||||
@ -529,7 +534,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
col.Attribute.IsNullable = false;
|
col.Attribute.IsNullable = false;
|
||||||
col.Attribute.DbType = col.Attribute.DbType.Replace("NOT NULL", "").Replace(" NULL", "").Trim();
|
col.Attribute.DbType = col.Attribute.DbType.Replace("NOT NULL", "").Replace(" NULL", "").Trim();
|
||||||
switch(common._orm.Ado.DataType)
|
switch (common._orm.Ado.DataType)
|
||||||
{
|
{
|
||||||
case DataType.Sqlite:
|
case DataType.Sqlite:
|
||||||
col.Attribute.DbType += " NOT NULL"; //sqlite 主键也可以插入 null
|
col.Attribute.DbType += " NOT NULL"; //sqlite 主键也可以插入 null
|
||||||
@ -538,6 +543,7 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
foreach (var col in trytb.Columns.Values)
|
foreach (var col in trytb.Columns.Values)
|
||||||
{
|
{
|
||||||
|
if (col.Attribute.IsPrimary == false && col.Attribute.IsIdentity) col.Attribute.CanUpdate = false;
|
||||||
var ltp = @"\(([^\)]+)\)";
|
var ltp = @"\(([^\)]+)\)";
|
||||||
col.DbTypeText = Regex.Replace(col.Attribute.DbType.Replace("NOT NULL", "").Replace(" NULL", "").Trim(), ltp, "");
|
col.DbTypeText = Regex.Replace(col.Attribute.DbType.Replace("NOT NULL", "").Replace(" NULL", "").Trim(), ltp, "");
|
||||||
var m = Regex.Match(col.Attribute.DbType, ltp);
|
var m = Regex.Match(col.Attribute.DbType, ltp);
|
||||||
@ -573,6 +579,10 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
trytb.IsRereadSql = trytb.Columns.Where(a => string.IsNullOrWhiteSpace(a.Value.Attribute.RereadSql) == false).Any();
|
trytb.IsRereadSql = trytb.Columns.Where(a => string.IsNullOrWhiteSpace(a.Value.Attribute.RereadSql) == false).Any();
|
||||||
|
trytb.ColumnsByPosition = columnsList.Where(a => a.Attribute.Position > 0).OrderBy(a => a.Attribute.Position)
|
||||||
|
.Concat(columnsList.Where(a => a.Attribute.Position == 0))
|
||||||
|
.Concat(columnsList.Where(a => a.Attribute.Position < 0).OrderBy(a => a.Attribute.Position)).ToArray();
|
||||||
|
trytb.ColumnsByCanUpdateDbUpdateValue = columnsList.Where(a => a.Attribute.CanUpdate == true && string.IsNullOrEmpty(a.DbUpdateValue) == false).ToArray();
|
||||||
tbc.AddOrUpdate(entity, trytb, (oldkey, oldval) => trytb);
|
tbc.AddOrUpdate(entity, trytb, (oldkey, oldval) => trytb);
|
||||||
|
|
||||||
#region 查找导航属性的关系、virtual 属性延时加载,动态产生新的重写类
|
#region 查找导航属性的关系、virtual 属性延时加载,动态产生新的重写类
|
||||||
@ -1673,12 +1683,12 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
internal static MethodInfo MethodDataReaderGetValue = typeof(Utils).GetMethod("InternalDataReaderGetValue", BindingFlags.Static | BindingFlags.NonPublic);
|
internal static MethodInfo MethodDataReaderGetValue = typeof(Utils).GetMethod("InternalDataReaderGetValue", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
internal static PropertyInfo PropertyDataReaderFieldCount = typeof(DbDataReader).GetProperty("FieldCount");
|
internal static PropertyInfo PropertyDataReaderFieldCount = typeof(DbDataReader).GetProperty("FieldCount");
|
||||||
internal static object InternalDataReaderGetValue(CommonUtils commonUtil, DbDataReader dr, int index)
|
internal static object InternalDataReaderGetValue(CommonUtils commonUtil, DbDataReader dr, int index, PropertyInfo property)
|
||||||
{
|
{
|
||||||
var orm = commonUtil._orm;
|
var orm = commonUtil._orm;
|
||||||
if (orm.Aop.AuditDataReaderHandler != null)
|
if (orm.Aop.AuditDataReaderHandler != null)
|
||||||
{
|
{
|
||||||
var args = new Aop.AuditDataReaderEventArgs(dr, index);
|
var args = new Aop.AuditDataReaderEventArgs(dr, index, property);
|
||||||
orm.Aop.AuditDataReaderHandler(orm, args);
|
orm.Aop.AuditDataReaderHandler(orm, args);
|
||||||
return args.Value;
|
return args.Value;
|
||||||
}
|
}
|
||||||
@ -1715,8 +1725,7 @@ namespace FreeSql.Internal
|
|||||||
|
|
||||||
if (type.IsArray) return Expression.Lambda<Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo>>(
|
if (type.IsArray) return Expression.Lambda<Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo>>(
|
||||||
Expression.New(RowInfo.Constructor,
|
Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { typeExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
||||||
|
|
||||||
@ -1726,8 +1735,7 @@ namespace FreeSql.Internal
|
|||||||
dicExecuteArrayRowReadClassOrTuple.ContainsKey(typeGeneric))
|
dicExecuteArrayRowReadClassOrTuple.ContainsKey(typeGeneric))
|
||||||
return Expression.Lambda<Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo>>(
|
return Expression.Lambda<Func<Type, int[], DbDataReader, int, CommonUtils, RowInfo>>(
|
||||||
Expression.New(RowInfo.Constructor,
|
Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { typeExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
), new[] { typeExp, indexesExp, rowExp, dataIndexExp, commonUtilExp }).Compile();
|
||||||
|
|
||||||
@ -1747,8 +1755,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
Expression read2ExpAssign = null; //加速缓存
|
Expression read2ExpAssign = null; //加速缓存
|
||||||
if (field.FieldType.IsArray) read2ExpAssign = Expression.New(RowInfo.Constructor,
|
if (field.FieldType.IsArray) read2ExpAssign = Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(field.FieldType, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(field.FieldType, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { Expression.Constant(field.FieldType), Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
@ -1757,8 +1764,7 @@ namespace FreeSql.Internal
|
|||||||
if (fieldtypeGeneric.IsNullableType()) fieldtypeGeneric = fieldtypeGeneric.GetGenericArguments().First();
|
if (fieldtypeGeneric.IsNullableType()) fieldtypeGeneric = fieldtypeGeneric.GetGenericArguments().First();
|
||||||
if (fieldtypeGeneric.IsEnum ||
|
if (fieldtypeGeneric.IsEnum ||
|
||||||
dicExecuteArrayRowReadClassOrTuple.ContainsKey(fieldtypeGeneric)) read2ExpAssign = Expression.New(RowInfo.Constructor,
|
dicExecuteArrayRowReadClassOrTuple.ContainsKey(fieldtypeGeneric)) read2ExpAssign = Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(field.FieldType, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(field.FieldType, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { Expression.Constant(field.FieldType), Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))
|
Expression.Add(dataIndexExp, Expression.Constant(1))
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
@ -1775,16 +1781,16 @@ namespace FreeSql.Internal
|
|||||||
Expression.IfThenElse(Expression.Equal(read2ExpValue, Expression.Constant(null)),
|
Expression.IfThenElse(Expression.Equal(read2ExpValue, Expression.Constant(null)),
|
||||||
Expression.Assign(Expression.MakeMemberAccess(ret2Exp, field), Expression.Default(field.FieldType)),
|
Expression.Assign(Expression.MakeMemberAccess(ret2Exp, field), Expression.Default(field.FieldType)),
|
||||||
Expression.Assign(Expression.MakeMemberAccess(ret2Exp, field), Expression.Convert(read2ExpValue, field.FieldType)))
|
Expression.Assign(Expression.MakeMemberAccess(ret2Exp, field), Expression.Convert(read2ExpValue, field.FieldType)))
|
||||||
//),
|
//),
|
||||||
//Expression.Catch(typeof(Exception), Expression.Block(
|
//Expression.Catch(typeof(Exception), Expression.Block(
|
||||||
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(0)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 0)))),
|
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(0)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 0)))),
|
||||||
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(1)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 1)))),
|
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(1)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 1)))),
|
||||||
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(2)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 2)))),
|
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(2)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 2)))),
|
||||||
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(3)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 3)))),
|
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(3)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 3)))),
|
||||||
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(4)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 4))))
|
// Expression.IfThen(Expression.Equal(read2ExpDataIndex, Expression.Constant(4)), Expression.Throw(Expression.Constant(new Exception(field.Name + "," + 4))))
|
||||||
// )
|
// )
|
||||||
//))
|
//))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
block2Exp.AddRange(new Expression[] {
|
block2Exp.AddRange(new Expression[] {
|
||||||
Expression.Return(returnTarget, Expression.New(RowInfo.Constructor, Expression.Convert(ret2Exp, typeof(object)), dataIndexExp)),
|
Expression.Return(returnTarget, Expression.New(RowInfo.Constructor, Expression.Convert(ret2Exp, typeof(object)), dataIndexExp)),
|
||||||
@ -1799,8 +1805,7 @@ namespace FreeSql.Internal
|
|||||||
Expression.IfThen(
|
Expression.IfThen(
|
||||||
Expression.LessThan(dataIndexExp, rowLenExp),
|
Expression.LessThan(dataIndexExp, rowLenExp),
|
||||||
Expression.Return(returnTarget, Expression.New(RowInfo.Constructor,
|
Expression.Return(returnTarget, Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })),
|
GetDataReaderValueBlockExpression(type, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Default(typeof(PropertyInfo)) })),
|
||||||
//Expression.Call(MethodGetDataReaderValue, new Expression[] { typeExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }) }),
|
|
||||||
Expression.Add(dataIndexExp, Expression.Constant(1))))
|
Expression.Add(dataIndexExp, Expression.Constant(1))))
|
||||||
),
|
),
|
||||||
Expression.Label(returnTarget, Expression.Default(typeof(RowInfo)))
|
Expression.Label(returnTarget, Expression.Default(typeof(RowInfo)))
|
||||||
@ -1819,7 +1824,7 @@ namespace FreeSql.Internal
|
|||||||
var name = row2.GetName(a);
|
var name = row2.GetName(a);
|
||||||
//expando[name] = row2.GetValue(a);
|
//expando[name] = row2.GetValue(a);
|
||||||
if (expandodic.ContainsKey(name)) continue;
|
if (expandodic.ContainsKey(name)) continue;
|
||||||
expandodic.Add(name, Utils.InternalDataReaderGetValue(commonUtils2, row2, a));
|
expandodic.Add(name, Utils.InternalDataReaderGetValue(commonUtils2, row2, a, null));
|
||||||
}
|
}
|
||||||
//expando = expandodic;
|
//expando = expandodic;
|
||||||
return new RowInfo(expandodic, fc);
|
return new RowInfo(expandodic, fc);
|
||||||
@ -1854,9 +1859,10 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
if (typetb.ColumnsByCsIgnore.ContainsKey(ctorParm.Name)) continue;
|
if (typetb.ColumnsByCsIgnore.ContainsKey(ctorParm.Name)) continue;
|
||||||
var readType = typetb.ColumnsByCs.TryGetValue(ctorParm.Name, out var trycol) ? trycol.Attribute.MapType : ctorParm.ParameterType;
|
var readType = typetb.ColumnsByCs.TryGetValue(ctorParm.Name, out var trycol) ? trycol.Attribute.MapType : ctorParm.ParameterType;
|
||||||
|
var colprop = trycol != null ? typetb.Table.Properties[trycol.CsName] : null;
|
||||||
|
|
||||||
var ispkExp = new List<Expression>();
|
var ispkExp = new List<Expression>();
|
||||||
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp }));
|
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Constant(colprop) }));
|
||||||
Expression readExpAssign = null; //加速缓存
|
Expression readExpAssign = null; //加速缓存
|
||||||
if (readType.IsArray) readExpAssign = Expression.New(RowInfo.Constructor,
|
if (readType.IsArray) readExpAssign = Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(readType, readpkvalExp),
|
GetDataReaderValueBlockExpression(readType, readpkvalExp),
|
||||||
@ -1872,7 +1878,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
|
|
||||||
//判断主键为空,则整个对象不读取
|
//判断主键为空,则整个对象不读取
|
||||||
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })));
|
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Constant(colprop) })));
|
||||||
if (trycol?.Attribute.IsPrimary == true)
|
if (trycol?.Attribute.IsPrimary == true)
|
||||||
{
|
{
|
||||||
ispkExp.Add(
|
ispkExp.Add(
|
||||||
@ -1975,7 +1981,7 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
var ispkExp = new List<Expression>();
|
var ispkExp = new List<Expression>();
|
||||||
var propGetSetMethod = prop.GetSetMethod(true);
|
var propGetSetMethod = prop.GetSetMethod(true);
|
||||||
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, tryidxExp }));
|
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, tryidxExp, Expression.Constant(prop) }));
|
||||||
Expression readExpAssign = null; //加速缓存
|
Expression readExpAssign = null; //加速缓存
|
||||||
if (readType.IsArray) readExpAssign = Expression.New(RowInfo.Constructor,
|
if (readType.IsArray) readExpAssign = Expression.New(RowInfo.Constructor,
|
||||||
GetDataReaderValueBlockExpression(readType, readpkvalExp),
|
GetDataReaderValueBlockExpression(readType, readpkvalExp),
|
||||||
@ -1991,7 +1997,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
|
|
||||||
//判断主键为空,则整个对象不读取
|
//判断主键为空,则整个对象不读取
|
||||||
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp })));
|
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(MethodDataReaderGetValue, new Expression[] { commonUtilExp, rowExp, dataIndexExp, Expression.Constant(prop) })));
|
||||||
if (flagStr.StartsWith("adoQuery") == false && //Ado.Query 的时候不作此判断
|
if (flagStr.StartsWith("adoQuery") == false && //Ado.Query 的时候不作此判断
|
||||||
trycol?.Attribute.IsPrimary == true) //若主键值为 null,则整行读取出来的对象为 null
|
trycol?.Attribute.IsPrimary == true) //若主键值为 null,则整行读取出来的对象为 null
|
||||||
{
|
{
|
||||||
@ -2078,7 +2084,7 @@ namespace FreeSql.Internal
|
|||||||
indexes2 = ctor.GetParameters().Select(c => row2.GetOrdinal(c.Name)).ToArray();
|
indexes2 = ctor.GetParameters().Select(c => row2.GetOrdinal(c.Name)).ToArray();
|
||||||
|
|
||||||
for (var c = 0; c < ctorParms.Length; c++)
|
for (var c = 0; c < ctorParms.Length; c++)
|
||||||
ctorParms[c] = Utils.InternalDataReaderGetValue(commonUtils2, row2, indexes2[c]);
|
ctorParms[c] = Utils.InternalDataReaderGetValue(commonUtils2, row2, indexes2[c], null);
|
||||||
return new RowInfo(ctor.Invoke(ctorParms), ctorParms.Length);
|
return new RowInfo(ctor.Invoke(ctorParms), ctorParms.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2438,6 +2444,14 @@ namespace FreeSql.Internal
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "System.DateTime":
|
case "System.DateTime":
|
||||||
|
if (TypeHandlers.ContainsKey(type))
|
||||||
|
{
|
||||||
|
foreach (var switchFunc in GetDataReaderValueBlockExpressionSwitchTypeFullName)
|
||||||
|
{
|
||||||
|
var switchFuncRet = switchFunc(returnTarget, valueExp, type);
|
||||||
|
if (switchFuncRet != null) return switchFuncRet;
|
||||||
|
}
|
||||||
|
}
|
||||||
tryparseExp = Expression.Block(
|
tryparseExp = Expression.Block(
|
||||||
new[] { tryparseVarExp = Expression.Variable(typeof(DateTime)) },
|
new[] { tryparseVarExp = Expression.Variable(typeof(DateTime)) },
|
||||||
new Expression[] {
|
new Expression[] {
|
||||||
|
@ -57,8 +57,18 @@ namespace FreeSql.ClickHouse
|
|||||||
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\"), "'"); //((Enum)val).ToInt64();
|
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\"), "'"); //((Enum)val).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -51,6 +51,9 @@ namespace FreeSql.Custom
|
|||||||
{
|
{
|
||||||
if (value == null) return "NULL";
|
if (value == null) return "NULL";
|
||||||
if (value.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
if (value.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
||||||
|
|
||||||
|
if (value is DateTime && Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(value)?.ToString();
|
||||||
|
if (value is DateTime? && Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler2)) return typeHandler2.Serialize(value)?.ToString();
|
||||||
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
}
|
}
|
||||||
public virtual string TimeSpanRawSql(object value) => value == null ? "NULL" : ((TimeSpan)value).TotalSeconds.ToString();
|
public virtual string TimeSpanRawSql(object value) => value == null ? "NULL" : ((TimeSpan)value).TotalSeconds.ToString();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -42,8 +42,18 @@ namespace FreeSql.Custom.MySql
|
|||||||
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\").Replace(", ", ","), "'"); //((Enum)val).ToInt64();
|
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\").Replace(", ", ","), "'"); //((Enum)val).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -68,7 +68,7 @@ namespace FreeSql.Custom.MySql
|
|||||||
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
||||||
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
|
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
|
||||||
public override string Now => "now()";
|
public override string Now => "now()";
|
||||||
public override string NowUtc => "current_timestamp()";
|
public override string NowUtc => "utc_timestamp()";
|
||||||
|
|
||||||
public override string QuoteWriteParamterAdapter(Type type, string paramterName)
|
public override string QuoteWriteParamterAdapter(Type type, string paramterName)
|
||||||
{
|
{
|
||||||
|
@ -56,8 +56,18 @@ namespace FreeSql.Custom.Oracle
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
||||||
else if (param is IEnumerable)
|
else if (param is IEnumerable)
|
||||||
|
@ -59,8 +59,8 @@ namespace FreeSql.Custom.Oracle
|
|||||||
if (enumType != null)
|
if (enumType != null)
|
||||||
{
|
{
|
||||||
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
||||||
CsToDb.New(DbType.Int32, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
CsToDb.New(DbType.Int32, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
||||||
CsToDb.New(DbType.Int64, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
CsToDb.New(DbType.Int64, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
||||||
if (_dicCsToDb.ContainsKey(type.FullName) == false)
|
if (_dicCsToDb.ContainsKey(type.FullName) == false)
|
||||||
{
|
{
|
||||||
lock (_dicCsToDbLock)
|
lock (_dicCsToDbLock)
|
||||||
|
@ -51,6 +51,9 @@ namespace FreeSql.Custom
|
|||||||
{
|
{
|
||||||
if (value == null) return "NULL";
|
if (value == null) return "NULL";
|
||||||
if (value.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
if (value.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
||||||
|
|
||||||
|
if (value is DateTime && Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(value)?.ToString();
|
||||||
|
if (value is DateTime? && Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler2)) return typeHandler2.Serialize(value)?.ToString();
|
||||||
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
}
|
}
|
||||||
public virtual string TimeSpanRawSql(object value) => value == null ? "NULL" : ((TimeSpan)value).TotalSeconds.ToString();
|
public virtual string TimeSpanRawSql(object value) => value == null ? "NULL" : ((TimeSpan)value).TotalSeconds.ToString();
|
||||||
|
@ -44,8 +44,18 @@ namespace FreeSql.Custom.PostgreSQL
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -49,11 +49,20 @@ namespace FreeSql.Custom.SqlServer
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
{
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
}
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is DateTimeOffset || param is DateTimeOffset?)
|
else if (param is DateTimeOffset || param is DateTimeOffset?)
|
||||||
{
|
{
|
||||||
if (param.Equals(DateTimeOffset.MinValue) == true) param = new DateTimeOffset(new DateTime(1970, 1, 1), TimeSpan.Zero);
|
if (param.Equals(DateTimeOffset.MinValue) == true) param = new DateTimeOffset(new DateTime(1970, 1, 1), TimeSpan.Zero);
|
||||||
|
@ -58,8 +58,18 @@ namespace FreeSql.Dameng
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
||||||
else if (param is IEnumerable)
|
else if (param is IEnumerable)
|
||||||
|
@ -60,8 +60,8 @@ namespace FreeSql.Dameng
|
|||||||
if (enumType != null)
|
if (enumType != null)
|
||||||
{
|
{
|
||||||
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
||||||
CsToDb.New(DmDbType.Int32, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
CsToDb.New(DmDbType.Int32, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
||||||
CsToDb.New(DmDbType.Int64, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
CsToDb.New(DmDbType.Int64, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
||||||
if (_dicCsToDb.ContainsKey(type.FullName) == false)
|
if (_dicCsToDb.ContainsKey(type.FullName) == false)
|
||||||
{
|
{
|
||||||
lock (_dicCsToDbLock)
|
lock (_dicCsToDbLock)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net60;netcoreapp3.1;netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>net60;netcoreapp3.1;netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -79,8 +79,18 @@ namespace FreeSql.Firebird
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("timestamp '", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
return string.Concat("timestamp '", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("timestamp '", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -57,12 +57,22 @@ namespace FreeSql.GBase
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
{
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
if (mapColumn?.DbPrecision > 0)
|
if (mapColumn?.DbPrecision > 0)
|
||||||
return string.Concat("'", ((DateTime)param).ToString($"yyyy-MM-dd HH:mm:ss.{"f".PadRight(mapColumn.DbPrecision, 'f')}"), "'");
|
return string.Concat("'", ((DateTime)param).ToString($"yyyy-MM-dd HH:mm:ss.{"f".PadRight(mapColumn.DbPrecision, 'f')}"), "'");
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
}
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
if (mapColumn?.DbPrecision > 0)
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString($"yyyy-MM-dd HH:mm:ss.{"f".PadRight(mapColumn.DbPrecision, 'f')}"), "'");
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
{
|
{
|
||||||
var ts = (TimeSpan)param;
|
var ts = (TimeSpan)param;
|
||||||
|
@ -100,8 +100,16 @@ namespace FreeSql.GBase
|
|||||||
var ts = (TimeSpan)value;
|
var ts = (TimeSpan)value;
|
||||||
return $"interval({ts.Days} {ts.Hours}:{ts.Minutes}:{ts.Seconds}.{ts.Milliseconds}) day(9) to fraction";
|
return $"interval({ts.Days} {ts.Hours}:{ts.Minutes}:{ts.Seconds}.{ts.Milliseconds}) day(9) to fraction";
|
||||||
}
|
}
|
||||||
if (type == typeof(DateTime) || type == typeof(DateTime?))
|
if (type == typeof(DateTime))
|
||||||
{
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(value)?.ToString();
|
||||||
|
if (col?.DbPrecision > 0)
|
||||||
|
return string.Concat("'", ((DateTime)value).ToString($"yyyy-MM-dd HH:mm:ss.{"f".PadRight(col.DbPrecision, 'f')}"), "'");
|
||||||
|
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
|
}
|
||||||
|
if (type == typeof(DateTime?))
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(value)?.ToString();
|
||||||
if (col?.DbPrecision > 0)
|
if (col?.DbPrecision > 0)
|
||||||
return string.Concat("'", ((DateTime)value).ToString($"yyyy-MM-dd HH:mm:ss.{"f".PadRight(col.DbPrecision, 'f')}"), "'");
|
return string.Concat("'", ((DateTime)value).ToString($"yyyy-MM-dd HH:mm:ss.{"f".PadRight(col.DbPrecision, 'f')}"), "'");
|
||||||
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -56,8 +56,18 @@ namespace FreeSql.KingbaseES
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -57,11 +57,20 @@ namespace FreeSql.MsAccess
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
{
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
}
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).TotalSeconds;
|
return ((TimeSpan)param).TotalSeconds;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net452;net451;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net452;net451;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -61,8 +61,18 @@ namespace FreeSql.MySql
|
|||||||
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\").Replace(", ", ","), "'"); //((Enum)val).ToInt64();
|
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\").Replace(", ", ","), "'"); //((Enum)val).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -100,7 +100,7 @@ namespace FreeSql.MySql
|
|||||||
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
||||||
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
|
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
|
||||||
public override string Now => "now()";
|
public override string Now => "now()";
|
||||||
public override string NowUtc => "current_timestamp()";
|
public override string NowUtc => "utc_timestamp()";
|
||||||
|
|
||||||
public override string QuoteWriteParamterAdapter(Type type, string paramterName)
|
public override string QuoteWriteParamterAdapter(Type type, string paramterName)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net60;net50;net45;netstandard2.1;netcoreapp2.1;netcoreapp3.1;</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net60;net50;net45;netstandard2.1;netcoreapp2.1;netcoreapp3.1;</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -118,7 +118,7 @@ namespace FreeSql.MySql
|
|||||||
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
||||||
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
|
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
|
||||||
public override string Now => "now()";
|
public override string Now => "now()";
|
||||||
public override string NowUtc => "current_timestamp()";
|
public override string NowUtc => "utc_timestamp()";
|
||||||
|
|
||||||
public override string QuoteWriteParamterAdapter(Type type, string paramterName)
|
public override string QuoteWriteParamterAdapter(Type type, string paramterName)
|
||||||
{
|
{
|
||||||
|
@ -59,8 +59,18 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
||||||
else if (param is IEnumerable)
|
else if (param is IEnumerable)
|
||||||
|
@ -61,8 +61,8 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
if (enumType != null)
|
if (enumType != null)
|
||||||
{
|
{
|
||||||
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
||||||
CsToDb.New(OdbcType.Int, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
CsToDb.New(OdbcType.Int, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
||||||
CsToDb.New(OdbcType.BigInt, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
CsToDb.New(OdbcType.BigInt, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
||||||
if (_dicCsToDb.ContainsKey(type.FullName) == false)
|
if (_dicCsToDb.ContainsKey(type.FullName) == false)
|
||||||
{
|
{
|
||||||
lock (_dicCsToDbLock)
|
lock (_dicCsToDbLock)
|
||||||
|
@ -51,6 +51,9 @@ namespace FreeSql.Odbc.Default
|
|||||||
{
|
{
|
||||||
if (value == null) return "NULL";
|
if (value == null) return "NULL";
|
||||||
if (value.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
if (value.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
||||||
|
|
||||||
|
if (value is DateTime && Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(value)?.ToString();
|
||||||
|
if (value is DateTime? && Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler2)) return typeHandler2.Serialize(value)?.ToString();
|
||||||
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
return string.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
}
|
}
|
||||||
public virtual string TimeSpanRawSql(object value) => value == null ? "NULL" : ((TimeSpan)value).TotalSeconds.ToString();
|
public virtual string TimeSpanRawSql(object value) => value == null ? "NULL" : ((TimeSpan)value).TotalSeconds.ToString();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -59,8 +59,18 @@ namespace FreeSql.Odbc.KingbaseES
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -59,8 +59,18 @@ namespace FreeSql.Odbc.MySql
|
|||||||
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\").Replace(", ", ","), "'"); //((Enum)val).ToInt64();
|
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\").Replace(", ", ","), "'"); //((Enum)val).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -64,7 +64,7 @@ namespace FreeSql.Odbc.MySql
|
|||||||
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
||||||
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
|
public override string Div(string left, string right, Type leftType, Type rightType) => $"{left} div {right}";
|
||||||
public override string Now => "now()";
|
public override string Now => "now()";
|
||||||
public override string NowUtc => "current_timestamp()";
|
public override string NowUtc => "utc_timestamp()";
|
||||||
|
|
||||||
public override string QuoteWriteParamterAdapter(Type type, string paramterName)
|
public override string QuoteWriteParamterAdapter(Type type, string paramterName)
|
||||||
{
|
{
|
||||||
|
@ -60,8 +60,18 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
||||||
else if (param is IEnumerable)
|
else if (param is IEnumerable)
|
||||||
|
@ -61,8 +61,8 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
if (enumType != null)
|
if (enumType != null)
|
||||||
{
|
{
|
||||||
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
||||||
CsToDb.New(OdbcType.Int, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
CsToDb.New(OdbcType.Int, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
||||||
CsToDb.New(OdbcType.BigInt, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
CsToDb.New(OdbcType.BigInt, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
||||||
if (_dicCsToDb.ContainsKey(type.FullName) == false)
|
if (_dicCsToDb.ContainsKey(type.FullName) == false)
|
||||||
{
|
{
|
||||||
lock (_dicCsToDbLock)
|
lock (_dicCsToDbLock)
|
||||||
|
@ -60,8 +60,18 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -64,11 +64,20 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
{
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
}
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is DateTimeOffset || param is DateTimeOffset?)
|
else if (param is DateTimeOffset || param is DateTimeOffset?)
|
||||||
{
|
{
|
||||||
if (param.Equals(DateTimeOffset.MinValue) == true) param = new DateTimeOffset(new DateTime(1970, 1, 1), TimeSpan.Zero);
|
if (param.Equals(DateTimeOffset.MinValue) == true) param = new DateTimeOffset(new DateTime(1970, 1, 1), TimeSpan.Zero);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;netstandard2.1;net60;net50;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;netstandard2.1;net60;net50;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -57,8 +57,18 @@ namespace FreeSql.Oracle
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("to_timestamp('", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "','YYYY-MM-DD HH24:MI:SS.FF6')");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
return $"numtodsinterval({((TimeSpan)param).Ticks * 1.0 / 10000000},'second')";
|
||||||
else if (param is IEnumerable)
|
else if (param is IEnumerable)
|
||||||
|
@ -96,8 +96,8 @@ namespace FreeSql.Oracle
|
|||||||
if (enumType != null)
|
if (enumType != null)
|
||||||
{
|
{
|
||||||
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
||||||
CsToDb.New(_dicCsToDb[typeof(int)].type, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
CsToDb.New(_dicCsToDb[typeof(int)].type, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
||||||
CsToDb.New(_dicCsToDb[typeof(long)].type, "number", $"number(32){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
CsToDb.New(_dicCsToDb[typeof(long)].type, "number", $"number(16){(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
||||||
if (_dicCsToDb.ContainsKey(type) == false)
|
if (_dicCsToDb.ContainsKey(type) == false)
|
||||||
{
|
{
|
||||||
lock (_dicCsToDbLock)
|
lock (_dicCsToDbLock)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net461;net452;net451;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net461;net452;net451;net45</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -61,8 +61,18 @@ namespace FreeSql.PostgreSQL
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -63,8 +63,18 @@ namespace FreeSql.QuestDb
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return (long)((TimeSpan)param).TotalSeconds;
|
return (long)((TimeSpan)param).TotalSeconds;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -57,8 +57,18 @@ namespace FreeSql.ShenTong
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).TotalSeconds;
|
return ((TimeSpan)param).TotalSeconds;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net60;net50;net451;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net60;net50;net451;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -68,11 +68,20 @@ namespace FreeSql.SqlServer
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
{
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
}
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
if (param.Equals(DateTime.MinValue) == true) param = new DateTime(1970, 1, 1);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is DateTimeOffset || param is DateTimeOffset?)
|
else if (param is DateTimeOffset || param is DateTimeOffset?)
|
||||||
{
|
{
|
||||||
if (param.Equals(DateTimeOffset.MinValue) == true) param = new DateTimeOffset(new DateTime(1970, 1, 1), TimeSpan.Zero);
|
if (param.Equals(DateTimeOffset.MinValue) == true) param = new DateTimeOffset(new DateTime(1970, 1, 1), TimeSpan.Zero);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net60;net50;net451;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net60;net50;net451;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -62,8 +62,18 @@ namespace FreeSql.Sqlite
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).TotalSeconds;
|
return ((TimeSpan)param).TotalSeconds;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.2.801-preview20230917</Version>
|
<Version>3.2.802-preview20231024</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -59,8 +59,18 @@ namespace FreeSql.Xugu
|
|||||||
return ((Enum)param).ToInt64();
|
return ((Enum)param).ToInt64();
|
||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
|
||||||
|
else if (param is DateTime)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
else if (param is DateTime?)
|
||||||
|
{
|
||||||
|
if (Utils.TypeHandlers.TryGetValue(typeof(DateTime?), out var typeHandler)) return typeHandler.Serialize(param);
|
||||||
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.ffffff"), "'");
|
||||||
|
}
|
||||||
|
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -22,39 +22,35 @@ namespace FreeSql.Xugu
|
|||||||
}
|
}
|
||||||
|
|
||||||
static object _dicCsToDbLock = new object();
|
static object _dicCsToDbLock = new object();
|
||||||
static Dictionary<string, CsToDb<XGDbType>> _dicCsToDb = new Dictionary<string, CsToDb<XGDbType>>() {
|
static Dictionary<Type, CsToDb<XGDbType>> _dicCsToDb = new Dictionary<Type, CsToDb<XGDbType>>() {
|
||||||
|
|
||||||
{
|
{ typeof(byte), CsToDb.New(XGDbType.SmallInt, "TINYINT","TINYINT NOT NULL", false, false, 0) },
|
||||||
typeof(byte).FullName,
|
{ typeof(byte?), CsToDb.New(XGDbType.SmallInt, "TINYINT", "TINYINT", false, true, null) },
|
||||||
CsToDb.New(XGDbType.SmallInt, "TINYINT","TINYINT NOT NULL", false, false, 0)
|
{ typeof(short), CsToDb.New(XGDbType.SmallInt, "SMALLINT","SMALLINT NOT NULL", false, false, 0) },{ typeof(short?), CsToDb.New(XGDbType.SmallInt, "SMALLINT", "SMALLINT", false, true, null) },
|
||||||
},
|
{ typeof(int), CsToDb.New(XGDbType.Int, "INTEGER","INTEGER NOT NULL", false, false, 0) },{ typeof(int?), CsToDb.New(XGDbType.Int, "INTEGER", "INTEGER", false, true, null) },
|
||||||
|
{ typeof(long), CsToDb.New(XGDbType.BigInt, "BIGINT","BIGINT NOT NULL", false, false, 0) },{ typeof(long?), CsToDb.New(XGDbType.BigInt, "BIGINT", "BIGINT", false, true, null) },
|
||||||
{ typeof(byte?).FullName, CsToDb.New(XGDbType.SmallInt, "TINYINT", "TINYINT", false, true, null) },
|
|
||||||
{ typeof(short).FullName, CsToDb.New(XGDbType.SmallInt, "SMALLINT","SMALLINT NOT NULL", false, false, 0) },{ typeof(short?).FullName, CsToDb.New(XGDbType.SmallInt, "SMALLINT", "SMALLINT", false, true, null) },
|
|
||||||
{ typeof(int).FullName, CsToDb.New(XGDbType.Int, "INTEGER","INTEGER NOT NULL", false, false, 0) },{ typeof(int?).FullName, CsToDb.New(XGDbType.Int, "INTEGER", "INTEGER", false, true, null) },
|
|
||||||
{ typeof(long).FullName, CsToDb.New(XGDbType.BigInt, "BIGINT","BIGINT NOT NULL", false, false, 0) },{ typeof(long?).FullName, CsToDb.New(XGDbType.BigInt, "BIGINT", "BIGINT", false, true, null) },
|
|
||||||
|
|
||||||
|
|
||||||
{ typeof(ushort).FullName, CsToDb.New(XGDbType.Int, "INT","INT NOT NULL", false, false, 0) },{ typeof(ushort?).FullName, CsToDb.New(XGDbType.Int, "INT", "INT", false, true, null) },
|
{ typeof(ushort), CsToDb.New(XGDbType.Int, "INT","INT NOT NULL", false, false, 0) },{ typeof(ushort?), CsToDb.New(XGDbType.Int, "INT", "INT", false, true, null) },
|
||||||
{ typeof(uint).FullName, CsToDb.New(XGDbType.BigInt, "BIGINT","BIGINT NOT NULL", false, false, 0) },{ typeof(uint?).FullName, CsToDb.New(XGDbType.BigInt, "BIGINT", "BIGINT", false, true, null) },
|
{ typeof(uint), CsToDb.New(XGDbType.BigInt, "BIGINT","BIGINT NOT NULL", false, false, 0) },{ typeof(uint?), CsToDb.New(XGDbType.BigInt, "BIGINT", "BIGINT", false, true, null) },
|
||||||
{ typeof(ulong).FullName, CsToDb.New(XGDbType.Numeric, "NUMERIC","NUMERIC(20,0) NOT NULL", false, false, 0) },{ typeof(ulong?).FullName, CsToDb.New(XGDbType.Numeric, "NUMERIC", "NUMERIC(20,0)", false, true, null) },
|
{ typeof(ulong), CsToDb.New(XGDbType.Numeric, "NUMERIC","NUMERIC(20,0) NOT NULL", false, false, 0) },{ typeof(ulong?), CsToDb.New(XGDbType.Numeric, "NUMERIC", "NUMERIC(20,0)", false, true, null) },
|
||||||
|
|
||||||
{ typeof(float).FullName, CsToDb.New(XGDbType.Real, "FLOAT","FLOAT NOT NULL", false, false, 0) },{ typeof(float?).FullName, CsToDb.New(XGDbType.Real, "FLOAT", "FLOAT", false, true, null) },
|
{ typeof(float), CsToDb.New(XGDbType.Real, "FLOAT","FLOAT NOT NULL", false, false, 0) },{ typeof(float?), CsToDb.New(XGDbType.Real, "FLOAT", "FLOAT", false, true, null) },
|
||||||
{ typeof(double).FullName, CsToDb.New(XGDbType.Double, "DOUBLE","DOUBLE NOT NULL", false, false, 0) },{ typeof(double?).FullName, CsToDb.New(XGDbType.Double, "DOUBLE", "DOUBLE", false, true, null) },
|
{ typeof(double), CsToDb.New(XGDbType.Double, "DOUBLE","DOUBLE NOT NULL", false, false, 0) },{ typeof(double?), CsToDb.New(XGDbType.Double, "DOUBLE", "DOUBLE", false, true, null) },
|
||||||
{ typeof(decimal).FullName, CsToDb.New(XGDbType.Numeric, "NUMERIC", "NUMERIC(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(XGDbType.Numeric, "NUMERIC", "NUMERIC(10,2)", false, true, null) },
|
{ typeof(decimal), CsToDb.New(XGDbType.Numeric, "NUMERIC", "NUMERIC(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?), CsToDb.New(XGDbType.Numeric, "NUMERIC", "NUMERIC(10,2)", false, true, null) },
|
||||||
|
|
||||||
{ typeof(string).FullName, CsToDb.New(XGDbType.VarChar, "VARCHAR", "VARCHAR(255)", false, null, "") },
|
{ typeof(string), CsToDb.New(XGDbType.VarChar, "VARCHAR", "VARCHAR(255)", false, null, "") },
|
||||||
|
|
||||||
{ typeof(char).FullName, CsToDb.New(XGDbType.Char, "CHAR", "CHAR(1)", false, null, '\0') },
|
{ typeof(char), CsToDb.New(XGDbType.Char, "CHAR", "CHAR(1)", false, null, '\0') },
|
||||||
|
|
||||||
//{ typeof(TimeSpan).FullName, CsToDb.New(XGDbType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(XGDbType.Time, "time", "time",false, true, null) },
|
//{ typeof(TimeSpan), CsToDb.New(XGDbType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?), CsToDb.New(XGDbType.Time, "time", "time",false, true, null) },
|
||||||
{ typeof(DateTime).FullName, CsToDb.New(XGDbType.DateTime, "DATETIME", "DATETIME NOT NULL", false, false, new DateTime(1970,1,1)) },
|
{ typeof(DateTime), CsToDb.New(XGDbType.DateTime, "DATETIME", "DATETIME NOT NULL", false, false, new DateTime(1970,1,1)) },
|
||||||
{ typeof(DateTime?).FullName, CsToDb.New(XGDbType.DateTime, "DATETIME", "DATETIME", false, true, null) },
|
{ typeof(DateTime?), CsToDb.New(XGDbType.DateTime, "DATETIME", "DATETIME", false, true, null) },
|
||||||
|
|
||||||
{ typeof(bool).FullName, CsToDb.New(XGDbType.Bool, "BOOLEAN","BOOLEAN NOT NULL", null, false, false) },{ typeof(bool?).FullName, CsToDb.New(XGDbType.Bool, "BOOLEAN","BOOLEAN", null, true, null) },
|
{ typeof(bool), CsToDb.New(XGDbType.Bool, "BOOLEAN","BOOLEAN NOT NULL", null, false, false) },{ typeof(bool?), CsToDb.New(XGDbType.Bool, "BOOLEAN","BOOLEAN", null, true, null) },
|
||||||
|
|
||||||
{ typeof(byte[]).FullName, CsToDb.New(XGDbType.VarBinary, "blob", "blob NULL", false, null, new byte[0]) },
|
{ typeof(byte[]), CsToDb.New(XGDbType.VarBinary, "blob", "blob NULL", false, null, new byte[0]) },
|
||||||
{ typeof(Guid).FullName, CsToDb.New(XGDbType.Char, "char", "char(36) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(XGDbType.Char, "char", "char(36) NULL", false, true, null) },
|
{ typeof(Guid), CsToDb.New(XGDbType.Char, "char", "char(36) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?), CsToDb.New(XGDbType.Char, "char", "char(36) NULL", false, true, null) },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -65,9 +61,30 @@ namespace FreeSql.Xugu
|
|||||||
|
|
||||||
public override DbInfoResult GetDbInfo(Type type)
|
public override DbInfoResult GetDbInfo(Type type)
|
||||||
{
|
{
|
||||||
_dicCsToDb.TryGetValue(type.FullName, out var info);
|
if (_dicCsToDb.TryGetValue(type, out var trydc)) return new DbInfoResult((int)trydc.type, trydc.dbtype, trydc.dbtypeFull, trydc.isnullable, trydc.defaultValue);
|
||||||
if (info == null) return null;
|
if (type.IsArray) return null;
|
||||||
return new DbInfoResult((int)info.type, info.dbtype, info.dbtypeFull, info.isnullable, info.defaultValue);
|
var enumType = type.IsEnum ? type : null;
|
||||||
|
if (enumType == null && type.IsNullableType())
|
||||||
|
{
|
||||||
|
var genericTypes = type.GetGenericArguments();
|
||||||
|
if (genericTypes.Length == 1 && genericTypes.First().IsEnum) enumType = genericTypes.First();
|
||||||
|
}
|
||||||
|
if (enumType != null)
|
||||||
|
{
|
||||||
|
var newItem = enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any() ?
|
||||||
|
CsToDb.New(_dicCsToDb[typeof(int)].type, "INT", $"INT{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue()) :
|
||||||
|
CsToDb.New(_dicCsToDb[typeof(long)].type, "BIGINT", $"BIGINT{(type.IsEnum ? " NOT NULL" : "")}", false, type.IsEnum ? false : true, enumType.CreateInstanceGetDefaultValue());
|
||||||
|
if (_dicCsToDb.ContainsKey(type) == false)
|
||||||
|
{
|
||||||
|
lock (_dicCsToDbLock)
|
||||||
|
{
|
||||||
|
if (_dicCsToDb.ContainsKey(type) == false)
|
||||||
|
_dicCsToDb.Add(type, newItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new DbInfoResult((int)newItem.type, newItem.dbtype, newItem.dbtypeFull, newItem.isnullable, newItem.defaultValue);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
internal static string GetXuguSqlTypeFullName(object[] row)
|
internal static string GetXuguSqlTypeFullName(object[] row)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ namespace FreeSql.Xugu
|
|||||||
case "VARCHAR": ret = XGDbType.VarChar; break;
|
case "VARCHAR": ret = XGDbType.VarChar; break;
|
||||||
case "CLOB": ret = XGDbType.LongVarChar; break;
|
case "CLOB": ret = XGDbType.LongVarChar; break;
|
||||||
|
|
||||||
//case "timestamp": ret = XGDbType.DateTime; break;
|
case "DATETIME": ret = XGDbType.DateTime; break;
|
||||||
//case "timestamptz": ret = XGDbType.DateTime; break;
|
//case "timestamptz": ret = XGDbType.DateTime; break;
|
||||||
//case "date": ret = XGDbType.Date; break;
|
//case "date": ret = XGDbType.Date; break;
|
||||||
//case "time": ret = XGDbType.Time; break;
|
//case "time": ret = XGDbType.Time; break;
|
||||||
@ -78,7 +78,7 @@ namespace FreeSql.Xugu
|
|||||||
//case "interval": ret = XGDbType.Interval; break;
|
//case "interval": ret = XGDbType.Interval; break;
|
||||||
|
|
||||||
case "BOOLEAN": ret = XGDbType.Bool; break;
|
case "BOOLEAN": ret = XGDbType.Bool; break;
|
||||||
//case "bytea": ret = XGDbType.Bytea; break;
|
case "BLOB": ret = XGDbType.LongVarBinary; break;
|
||||||
//case "bit": ret = XGDbType.Bool; break;
|
//case "bit": ret = XGDbType.Bool; break;
|
||||||
//case "varbit": ret = XGDbType.Varbit; break;
|
//case "varbit": ret = XGDbType.Varbit; break;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ namespace FreeSql.Xugu
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(parameterName)) parameterName = $"p_{_params?.Count}";
|
if (string.IsNullOrEmpty(parameterName)) parameterName = $"p_{_params?.Count}";
|
||||||
if (value != null) value = getParamterValue(type, value);
|
if (value != null) value = getParamterValue(type, value);
|
||||||
var ret = new XGParameters { ParameterName = QuoteParamterName(parameterName), Value = value };
|
var ret = new XGParameters { ParameterName = parameterName, Value = value };
|
||||||
|
|
||||||
var tp = _orm.CodeFirst.GetDbInfo(type)?.type;
|
var tp = _orm.CodeFirst.GetDbInfo(type)?.type;
|
||||||
if (col != null)
|
if (col != null)
|
||||||
@ -109,10 +109,10 @@ namespace FreeSql.Xugu
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) =>
|
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) =>
|
||||||
Utils.GetDbParamtersByObject<XGParameters>(sql, obj, "@", (name, type, value) =>
|
Utils.GetDbParamtersByObject<XGParameters>(sql, obj, ":", (name, type, value) =>
|
||||||
{
|
{
|
||||||
if (value != null) value = getParamterValue(type, value);
|
if (value != null) value = getParamterValue(type, value);
|
||||||
var ret = new XGParameters { ParameterName = $"@{name}", Value = value };
|
var ret = new XGParameters { ParameterName = name, Value = value };
|
||||||
|
|
||||||
var tp = _orm.CodeFirst.GetDbInfo(type)?.type;
|
var tp = _orm.CodeFirst.GetDbInfo(type)?.type;
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ namespace FreeSql.Xugu
|
|||||||
return $"{nametrim.Trim('"').Replace("\".\"", ".").Replace(".\"", ".")}";
|
return $"{nametrim.Trim('"').Replace("\".\"", ".").Replace(".\"", ".")}";
|
||||||
}
|
}
|
||||||
public override string[] SplitTableName(string name) => GetSplitTableNames(name, '"', '"', 2);
|
public override string[] SplitTableName(string name) => GetSplitTableNames(name, '"', '"', 2);
|
||||||
public override string QuoteParamterName(string name) => $"@{name}";
|
public override string QuoteParamterName(string name) => $":{name}";
|
||||||
public override string IsNull(string sql, object value) => $"coalesce({sql}, {value})";
|
public override string IsNull(string sql, object value) => $"coalesce({sql}, {value})";
|
||||||
public override string StringConcat(string[] objs, Type[] types) => $"{string.Join(" || ", objs)}";
|
public override string StringConcat(string[] objs, Type[] types) => $"{string.Join(" || ", objs)}";
|
||||||
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
public override string Mod(string left, string right, Type leftType, Type rightType) => $"{left} % {right}";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user