mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 修复 non public ctor #291
This commit is contained in:
parent
4fcad4a797
commit
d55d7a5374
@ -135,9 +135,35 @@ namespace FreeSql.Tests
|
|||||||
[Column(Name = "EDII_EDI_ID")] public long EdiId { get; set; }
|
[Column(Name = "EDII_EDI_ID")] public long EdiId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Song123
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
protected Song123() { }
|
||||||
|
public Song123(long id) => Id = id;
|
||||||
|
}
|
||||||
|
public class Author123
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public long SongId { get; set; }
|
||||||
|
public Author123(long id, long songId)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
SongId = songId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Test03()
|
public void Test03()
|
||||||
{
|
{
|
||||||
|
g.sqlite.Delete<Song123>().Where("1=1").ExecuteAffrows();
|
||||||
|
g.sqlite.Delete<Author123>().Where("1=1").ExecuteAffrows();
|
||||||
|
g.sqlite.Insert(new Song123(1)).ExecuteAffrows();
|
||||||
|
g.sqlite.Insert(new Author123(11, 1)).ExecuteAffrows();
|
||||||
|
var song = g.sqlite.Select<Song123>()
|
||||||
|
.From<Author123>((a, b) => a.InnerJoin(a1 => a1.Id == b.SongId))
|
||||||
|
.First((a, b) => a); // throw error
|
||||||
|
Console.WriteLine(song == null);
|
||||||
|
|
||||||
g.sqlite.Select<Edi>().ToList();
|
g.sqlite.Select<Edi>().ToList();
|
||||||
|
|
||||||
var itemId2 = 2;
|
var itemId2 = 2;
|
||||||
|
@ -130,7 +130,7 @@ public static partial class FreeSqlGlobalExtensions
|
|||||||
if (that == typeof(string)) return default(string);
|
if (that == typeof(string)) return default(string);
|
||||||
if (that.IsArray) return Array.CreateInstance(that, 0);
|
if (that.IsArray) return Array.CreateInstance(that, 0);
|
||||||
var ctorParms = that.InternalGetTypeConstructor0OrFirst(false)?.GetParameters();
|
var ctorParms = that.InternalGetTypeConstructor0OrFirst(false)?.GetParameters();
|
||||||
if (ctorParms == null || ctorParms.Any() == false) return Activator.CreateInstance(that, null);
|
if (ctorParms == null || ctorParms.Any() == false) return Activator.CreateInstance(that, true);
|
||||||
return Activator.CreateInstance(that, ctorParms.Select(a => a.ParameterType.IsInterface || a.ParameterType.IsAbstract || a.ParameterType == typeof(string) ? null : Activator.CreateInstance(a.ParameterType, null)).ToArray());
|
return Activator.CreateInstance(that, ctorParms.Select(a => a.ParameterType.IsInterface || a.ParameterType.IsAbstract || a.ParameterType == typeof(string) ? null : Activator.CreateInstance(a.ParameterType, null)).ToArray());
|
||||||
}
|
}
|
||||||
internal static NewExpression InternalNewExpression(this Type that)
|
internal static NewExpression InternalNewExpression(this Type that)
|
||||||
|
@ -190,7 +190,7 @@ Elapsed: 00:00:00.6495301; Query Entity Counts: 131072; ORM: Dapper
|
|||||||
|
|
||||||
## 💕 Donation
|
## 💕 Donation
|
||||||
|
|
||||||
L*y 58元、花花 88元、麦兜很乖 50元、网络来者 2000元、John 99.99元、alex 666元、bacongao 36元、无名 100元、Eternity 188元、无名 10元、⌒.Helper~..oO 66元、习惯与被习惯 100元、无名 100元、蔡易喋 88元
|
L*y 58元、花花 88元、麦兜很乖 50元、网络来者 2000元、John 99.99元、alex 666元、bacongao 36元、无名 100元、Eternity 188元、无名 10元、⌒.Helper~..oO 66元、习惯与被习惯 100元、无名 100元、蔡易喋 88.88元
|
||||||
|
|
||||||
> Thank you for your donation
|
> Thank you for your donation
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user