- 优化 表达式 true && ... 解析的处理;

- 优化 Navigate 指定联合键关系时,对属性顺序的要求,当类型不一样、名称一样时无须指明属性的顺序,如:[Navigate("MemberId, ShopId")];
This commit is contained in:
28810
2019-07-04 19:46:51 +08:00
parent 619c57c254
commit 3ebc01f88d
16 changed files with 265 additions and 42 deletions

View File

@ -21,7 +21,6 @@
<Folder Include="DataAnnotations\MySql\" />
<Folder Include="DataAnnotations\SqlServer\" />
<Folder Include="DataContext\MySql\" />
<Folder Include="Other\" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,89 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
// Website: http://www.freesql.net
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Newtonsoft.Json;
using FreeSql.DataAnnotations;
namespace ZX.Model {
[JsonObject(MemberSerialization.OptIn)]
public class CustomerCheckupGroup {
[JsonProperty, Column(IsPrimary = true)]
public short ShopId { get => _ShopId; set {
if (_ShopId == value) return;
_ShopId = value;
} }
private short _ShopId;
[JsonProperty, Column(DbType = "varchar(50)", IsPrimary = true)]
public string Id { get; set; }
[JsonProperty, Column(DbType = "nvarchar(50)")]
public string MemberId { get => _MemberId; set {
if (_MemberId == value) return;
_MemberId = value;
} }
private string _MemberId;
[JsonProperty, Column(DbType = "varchar(50)")]
public string Discount { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Doctor { get; set; }
[JsonProperty]
public DateTime? FirstTime { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Group { get; set; }
[JsonProperty]
public DateTime? InsertTime { get; set; }
[JsonProperty, Column(Name = "isOK")]
public bool? IsOK { get; set; }
[JsonProperty, Column(Name = "isPay", DbType = "varchar(50)")]
public string IsPay { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Office { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string PayType { get; set; }
[JsonProperty, Column(DbType = "decimal(9,2)")]
public decimal? Price { get; set; }
[JsonProperty]
public DateTime? UpdateTime { get; set; }
[JsonProperty, Column(DbType = "decimal(9,2)")]
public decimal? Value { get; set; }
#region => ManyToOne/OneToOne
[Navigate("ShopId, MemberId")]
public virtual CustomerMember CustomerMember { get; set; }
#endregion
#region => ManyToMany
#endregion
}
}

View File

@ -0,0 +1,108 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
// Website: http://www.freesql.net
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Newtonsoft.Json;
using FreeSql.DataAnnotations;
namespace ZX.Model {
[JsonObject(MemberSerialization.OptIn)]
public class CustomerMember {
public CustomerMember()
{
CheckupGroups = new List<CustomerCheckupGroup>();
}
[JsonProperty, Column(DbType = "nvarchar(50)", IsPrimary = true)]
public string MemberId { get; set; }
[JsonProperty, Column(IsPrimary = true)]
public short ShopId { get; set; }
[JsonProperty]
public long? CustomerId { get => _CustomerId; set {
if (_CustomerId == value) return;
_CustomerId = value;
} }
private long? _CustomerId;
[JsonProperty, Column(DbType = "varchar(500)")]
public string Address { get; set; }
[JsonProperty, Column(DbType = "smalldatetime")]
public DateTime? Birthday { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string CardNo { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string CardType { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Doctor { get; set; }
[JsonProperty]
public DateTime? EndDate { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Group { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Marry { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Name { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Part { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string PayType { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Phone { get; set; }
[JsonProperty, Column(DbType = "varchar(10)")]
public string Sex { get; set; }
[JsonProperty]
public DateTime? StartDate { get; set; }
[JsonProperty, Column(DbType = "text")]
public string Suggest { get; set; }
[JsonProperty, Column(DbType = "text")]
public string SumUp { get; set; }
[JsonProperty, Column(DbType = "varchar(50)")]
public string Team { get; set; }
[JsonProperty, Column(DbType = "decimal(9,2)")]
public decimal? TotalFee { get; set; }
#region => ManyToOne/OneToOne
[Navigate("MemberId,ShopId")]
public virtual List<CustomerCheckupGroup> CheckupGroups { get; set; }
#endregion
#region => ManyToMany
#endregion
}
}

View File

@ -296,6 +296,14 @@ namespace FreeSql.Tests
[Fact]
public void Test1()
{
var teklksjdg = g.sqlite.Select<ZX.Model.CustomerCheckupGroup>()
.Where(a => true && a.CustomerMember.Group == "xxx")
.ToSql();
var sklgjlskdg = g.sqlite.Select<ZX.Model.CustomerMember>()
.Where(a => a.CheckupGroups.AsSelect().Any())
.ToSql();
var tkdkdksql = g.sqlite.Select<TaskBuild>().From<Templates, Templates>((a, b, c) =>
a.LeftJoin(aa => aa.TemplatesId == b.Id2 && b.Code == "xx")
.LeftJoin(aa => aa.TemplatesId == c.Id2))