mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-03-11 08:30:56 +08:00
Merge branch 'master' of https://github.com/2881099/FreeSql
This commit is contained in:
@@ -758,5 +758,13 @@
|
|||||||
<param name="that"></param>
|
<param name="that"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Reflection.Assembly[])">
|
||||||
|
<summary>
|
||||||
|
批量注入 Repository,可以参考代码自行调整
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="assemblies"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using System.Numerics;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using static System.Runtime.CompilerServices.RuntimeHelpers;
|
||||||
|
|
||||||
namespace FreeSql.Internal
|
namespace FreeSql.Internal
|
||||||
{
|
{
|
||||||
@@ -1003,6 +1004,7 @@ namespace FreeSql.Internal
|
|||||||
var midTypePropsTrytb = tbmid.Properties.Where(a => a.Value.PropertyType == trytb.Type).FirstOrDefault().Value;
|
var midTypePropsTrytb = tbmid.Properties.Where(a => a.Value.PropertyType == trytb.Type).FirstOrDefault().Value;
|
||||||
//g.mysql.Select<Tag>().Where(a => g.mysql.Select<Song_tag>().Where(b => b.Tag_id == a.Id && b.Song_id == 1).Any());
|
//g.mysql.Select<Tag>().Where(a => g.mysql.Select<Song_tag>().Where(b => b.Tag_id == a.Id && b.Song_id == 1).Any());
|
||||||
var lmbdWhere = isLazy ? new StringBuilder() : null;
|
var lmbdWhere = isLazy ? new StringBuilder() : null;
|
||||||
|
var minPkCols = new List<ColumnInfo>();
|
||||||
|
|
||||||
if (pnvAttr?.ManyToMany != null)
|
if (pnvAttr?.ManyToMany != null)
|
||||||
{
|
{
|
||||||
@@ -1039,6 +1041,8 @@ namespace FreeSql.Internal
|
|||||||
if (tbmid.Primarys.Any() == false)
|
if (tbmid.Primarys.Any() == false)
|
||||||
foreach (var c in trytbTf.Columns)
|
foreach (var c in trytbTf.Columns)
|
||||||
tbmid.ColumnsByCs[c.CsName].Attribute.IsPrimary = true;
|
tbmid.ColumnsByCs[c.CsName].Attribute.IsPrimary = true;
|
||||||
|
else
|
||||||
|
minPkCols.AddRange(trytbTf.Columns);
|
||||||
|
|
||||||
if (isLazy)
|
if (isLazy)
|
||||||
{
|
{
|
||||||
@@ -1086,6 +1090,8 @@ namespace FreeSql.Internal
|
|||||||
if (tbmid.Primarys.Any() == false)
|
if (tbmid.Primarys.Any() == false)
|
||||||
foreach (var c in tbrefTf.Columns)
|
foreach (var c in tbrefTf.Columns)
|
||||||
tbmid.ColumnsByCs[c.CsName].Attribute.IsPrimary = true;
|
tbmid.ColumnsByCs[c.CsName].Attribute.IsPrimary = true;
|
||||||
|
else
|
||||||
|
minPkCols.AddRange(tbrefTf.Columns);
|
||||||
|
|
||||||
if (isLazy)
|
if (isLazy)
|
||||||
{
|
{
|
||||||
@@ -1129,6 +1135,8 @@ namespace FreeSql.Internal
|
|||||||
nvref.MiddleColumns.Add(trycol);
|
nvref.MiddleColumns.Add(trycol);
|
||||||
if (tbmid.Primarys.Any() == false)
|
if (tbmid.Primarys.Any() == false)
|
||||||
trycol.Attribute.IsPrimary = true;
|
trycol.Attribute.IsPrimary = true;
|
||||||
|
else
|
||||||
|
minPkCols.Add(trycol);
|
||||||
|
|
||||||
if (isLazy)
|
if (isLazy)
|
||||||
{
|
{
|
||||||
@@ -1169,6 +1177,8 @@ namespace FreeSql.Internal
|
|||||||
nvref.MiddleColumns.Add(trycol);
|
nvref.MiddleColumns.Add(trycol);
|
||||||
if (tbmid.Primarys.Any() == false)
|
if (tbmid.Primarys.Any() == false)
|
||||||
trycol.Attribute.IsPrimary = true;
|
trycol.Attribute.IsPrimary = true;
|
||||||
|
else
|
||||||
|
minPkCols.Add(trycol);
|
||||||
|
|
||||||
if (isLazy) lmbdWhere.Append(" && b.").Append(trycol.CsName).Append(" == a.").Append(tbref.Primarys[a].CsName);
|
if (isLazy) lmbdWhere.Append(" && b.").Append(trycol.CsName).Append(" == a.").Append(tbref.Primarys[a].CsName);
|
||||||
}
|
}
|
||||||
@@ -1197,6 +1207,11 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(minPkCols.Any(c => tbmid.ColumnsByCs[c.CsName].Attribute.IsPrimary == false))
|
||||||
|
{
|
||||||
|
nvref.Exception = new Exception($"导航属性 {trytbTypeName}.{pnv.Name} 解析错误,中间类主键错误:{midType.Name}({string.Join(",", tbmid.Primarys.Select(a => a.CsName))}) 与两边不匹配");
|
||||||
|
trytb.AddOrUpdateTableRef(pnv.Name, nvref);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLazy)
|
if (isLazy)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace FreeSql.Custom.PostgreSQL
|
|||||||
{ typeof(decimal).FullName, CsToDb.New(DbType.Decimal, "numeric", "numeric(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(DbType.Decimal, "numeric", "numeric(10,2)", false, true, null) },
|
{ typeof(decimal).FullName, CsToDb.New(DbType.Decimal, "numeric", "numeric(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(DbType.Decimal, "numeric", "numeric(10,2)", false, true, null) },
|
||||||
|
|
||||||
{ typeof(string).FullName, CsToDb.New(DbType.String, "varchar", "varchar(255)", false, null, "") },
|
{ typeof(string).FullName, CsToDb.New(DbType.String, "varchar", "varchar(255)", false, null, "") },
|
||||||
{ typeof(char).FullName, CsToDb.New(DbType.AnsiString, "char", "char(1) NULL", false, null, '\0') },
|
{ typeof(char).FullName, CsToDb.New(DbType.AnsiString, "bpchar", "bpchar(1) NULL", false, null, '\0') },
|
||||||
|
|
||||||
{ typeof(TimeSpan).FullName, CsToDb.New(DbType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(DbType.Time, "time", "time",false, true, null) },
|
{ typeof(TimeSpan).FullName, CsToDb.New(DbType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(DbType.Time, "time", "time",false, true, null) },
|
||||||
{ typeof(DateTime).FullName, CsToDb.New(DbType.DateTime, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(DbType.DateTime, "timestamp", "timestamp", false, true, null) },
|
{ typeof(DateTime).FullName, CsToDb.New(DbType.DateTime, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(DbType.DateTime, "timestamp", "timestamp", false, true, null) },
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
{ typeof(decimal).FullName, CsToDb.New(OdbcType.Numeric, "numeric", "numeric(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(OdbcType.Numeric, "numeric", "numeric(10,2)", false, true, null) },
|
{ typeof(decimal).FullName, CsToDb.New(OdbcType.Numeric, "numeric", "numeric(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(OdbcType.Numeric, "numeric", "numeric(10,2)", false, true, null) },
|
||||||
|
|
||||||
{ typeof(string).FullName, CsToDb.New(OdbcType.VarChar, "varchar", "varchar(255)", false, null, "") },
|
{ typeof(string).FullName, CsToDb.New(OdbcType.VarChar, "varchar", "varchar(255)", false, null, "") },
|
||||||
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, "char", "char(1) NULL", false, null, '\0') },
|
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, "bpchar", "bpchar(1) NULL", false, null, '\0') },
|
||||||
|
|
||||||
{ typeof(TimeSpan).FullName, CsToDb.New(OdbcType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(OdbcType.Time, "time", "time",false, true, null) },
|
{ typeof(TimeSpan).FullName, CsToDb.New(OdbcType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(OdbcType.Time, "time", "time",false, true, null) },
|
||||||
{ typeof(DateTime).FullName, CsToDb.New(OdbcType.DateTime, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(OdbcType.DateTime, "timestamp", "timestamp", false, true, null) },
|
{ typeof(DateTime).FullName, CsToDb.New(OdbcType.DateTime, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(OdbcType.DateTime, "timestamp", "timestamp", false, true, null) },
|
||||||
|
|||||||
Reference in New Issue
Block a user