Skip to content

Commit fb7eb01

Browse files
committed
- 修复 OracleOledb 引起的读取类型问题;
- 调整 DynamicEntity API;#1505
1 parent 0d4199e commit fb7eb01

File tree

14 files changed

+109
-450
lines changed

14 files changed

+109
-450
lines changed

Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs

Lines changed: 0 additions & 92 deletions
This file was deleted.

Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj

Lines changed: 0 additions & 42 deletions
This file was deleted.

Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml

Lines changed: 0 additions & 81 deletions
This file was deleted.
-596 Bytes
Binary file not shown.

FreeSql.DbContext/FreeSql.DbContext.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ namespace FreeSql.Tests.DynamicEntity
1111
{
1212
public class DynamicEntityTest
1313
{
14-
private static IFreeSql fsql = new FreeSqlBuilder().UseConnectionString(DataType.PostgreSQL,
15-
"Host=192.168.0.36;Port=5432;Username=postgres;Password=123; Database=test;ArrayNullabilityMode=Always;Pooling=true;Minimum Pool Size=1")
14+
private static IFreeSql fsql = new FreeSqlBuilder().UseConnectionString(DataType.Sqlite,
15+
"data source=:memory:")
1616
.UseMonitorCommand(d => Console.WriteLine(d.CommandText)).Build();
1717

1818
[Fact]
1919
public void NormalTest()
2020
{
21-
Type type = DynamicCompileHelper.DynamicBuilder()
22-
.Class("NormalUsers")
21+
var table = fsql.CodeFirst.DynamicEntity("NormalUsers")
2322
.Property("Id", typeof(string))
2423
.Property("Name", typeof(string))
2524
.Property("Address", typeof(string))
@@ -30,18 +29,17 @@ public void NormalTest()
3029
["Id"] = Guid.NewGuid().ToString(),
3130
["Address"] = "北京市"
3231
};
33-
var instance = DynamicCompileHelper.CreateObjectByType(type, dict);
32+
var instance = table.CreateInstance(dict);
3433
//根据Type生成表
35-
fsql.CodeFirst.SyncStructure(type);
36-
fsql.Insert<object>().AsType(type).AppendData(instance).ExecuteAffrows();
34+
fsql.CodeFirst.SyncStructure(table.Type);
35+
fsql.Insert<object>().AsType(table.Type).AppendData(instance).ExecuteAffrows();
3736
}
3837

3938
[Fact]
4039
public void AttributeTest()
4140
{
42-
Type type = DynamicCompileHelper.DynamicBuilder()
43-
.Class("AttributeUsers", new TableAttribute() { Name = "T_Attribute_User" },
44-
new IndexAttribute("Name_Index", "Name", false))
41+
var table = fsql.CodeFirst.DynamicEntity("AttributeUsers", new TableAttribute() { Name = "T_Attribute_User" },
42+
new IndexAttribute("Name_Index1", "Name", false))
4543
.Property("Id", typeof(int),
4644
new ColumnAttribute() { IsPrimary = true, IsIdentity = true, Position = 1 })
4745
.Property("Name", typeof(string),
@@ -54,19 +52,18 @@ public void AttributeTest()
5452
["Name"] = "张三",
5553
["Address"] = "北京市"
5654
};
57-
var instance = DynamicCompileHelper.CreateObjectByType(type, dict);
55+
var instance = table.CreateInstance(dict);
5856
//根据Type生成表
59-
fsql.CodeFirst.SyncStructure(type);
60-
var insertId = fsql.Insert<object>().AsType(type).AppendData(instance).ExecuteIdentity();
61-
var select = fsql.Select<object>().AsType(type).ToList();
57+
fsql.CodeFirst.SyncStructure(table.Type);
58+
var insertId = fsql.Insert<object>().AsType(table.Type).AppendData(instance).ExecuteIdentity();
59+
var select = fsql.Select<object>().AsType(table.Type).ToList();
6260
}
6361

6462
[Fact]
6563
public void SuperClassTest()
6664
{
67-
Type type = DynamicCompileHelper.DynamicBuilder()
68-
.Class("Roles", new TableAttribute() { Name = "T_Role" },
69-
new IndexAttribute("Name_Index", "Name", false))
65+
var table = fsql.CodeFirst.DynamicEntity("Roles", new TableAttribute() { Name = "T_Role" },
66+
new IndexAttribute("Name_Index2", "Name", false))
7067
.Extend(typeof(BaseModel))
7168
.Property("Id", typeof(int),
7269
new ColumnAttribute() { IsPrimary = true, IsIdentity = true, Position = 1 })
@@ -79,10 +76,10 @@ public void SuperClassTest()
7976
["UpdateTime"] = DateTime.Now,
8077
["UpdatePerson"] = "admin"
8178
};
82-
var instance = DynamicCompileHelper.CreateObjectByType(type, dict);
79+
var instance = table.CreateInstance(dict);
8380
//根据Type生成表
84-
fsql.CodeFirst.SyncStructure(type);
85-
fsql.Insert<object>().AsType(type).AppendData(instance).ExecuteAffrows();
81+
fsql.CodeFirst.SyncStructure(table.Type);
82+
fsql.Insert<object>().AsType(table.Type).AppendData(instance).ExecuteAffrows();
8683
}
8784
}
8885
public class BaseModel

FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
</ItemGroup>
3636

3737
<ItemGroup>
38-
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.DynamicEntity\FreeSql.Extensions.DynamicEntity.csproj" />
3938
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.LazyLoading\FreeSql.Extensions.LazyLoading.csproj" />
4039
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.Linq\FreeSql.Extensions.Linq.csproj" />
4140
<ProjectReference Include="..\..\FreeSql.DbContext\FreeSql.DbContext.csproj" />

FreeSql.sln

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.Xugu", "Pr
125125
EndProject
126126
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.Xugu", "FreeSql.Tests\FreeSql.Tests.Provider.Xugu\FreeSql.Tests.Provider.Xugu.csproj", "{16C21D77-20AC-4722-AD97-F53BDDE8210C}"
127127
EndProject
128-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.DynamicEntity", "Extensions\FreeSql.Extensions.DynamicEntity\FreeSql.Extensions.DynamicEntity.csproj", "{FC4639EC-7787-4F85-AC02-26875E39E573}"
129-
EndProject
130128
Global
131129
GlobalSection(SolutionConfigurationPlatforms) = preSolution
132130
Debug|Any CPU = Debug|Any CPU
@@ -749,18 +747,6 @@ Global
749747
{16C21D77-20AC-4722-AD97-F53BDDE8210C}.Release|x64.Build.0 = Release|Any CPU
750748
{16C21D77-20AC-4722-AD97-F53BDDE8210C}.Release|x86.ActiveCfg = Release|Any CPU
751749
{16C21D77-20AC-4722-AD97-F53BDDE8210C}.Release|x86.Build.0 = Release|Any CPU
752-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
753-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|Any CPU.Build.0 = Debug|Any CPU
754-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|x64.ActiveCfg = Debug|Any CPU
755-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|x64.Build.0 = Debug|Any CPU
756-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|x86.ActiveCfg = Debug|Any CPU
757-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|x86.Build.0 = Debug|Any CPU
758-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Release|Any CPU.ActiveCfg = Release|Any CPU
759-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Release|Any CPU.Build.0 = Release|Any CPU
760-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Release|x64.ActiveCfg = Release|Any CPU
761-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Release|x64.Build.0 = Release|Any CPU
762-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Release|x86.ActiveCfg = Release|Any CPU
763-
{FC4639EC-7787-4F85-AC02-26875E39E573}.Release|x86.Build.0 = Release|Any CPU
764750
EndGlobalSection
765751
GlobalSection(SolutionProperties) = preSolution
766752
HideSolutionNode = FALSE
@@ -801,7 +787,6 @@ Global
801787
{8A06B18A-A8BF-4AEA-AFE4-0F573C2DBFEE} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
802788
{71A6F937-D11B-4AE4-9933-BB6B4D925665} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
803789
{8064870C-22EA-4A58-972D-DBD57D096D91} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
804-
{FC4639EC-7787-4F85-AC02-26875E39E573} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
805790
EndGlobalSection
806791
GlobalSection(ExtensibilityGlobals) = postSolution
807792
RESX_NeutralResourcesLanguage = en-US

0 commit comments

Comments
 (0)