Skip to content

Commit 658d049

Browse files
author
lianggx
committed
fix bug
1 parent a37d161 commit 658d049

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

.vs/MyStaging/v15/.suo

0 Bytes
Binary file not shown.

MyStaging.xUnitTest/QueryContextTest.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@ public void ToList()
8888
{
8989
var list = User.Context.OrderByDescing(f => f.Createtime).Page(1, 10).ToList();
9090

91-
Assert.Equal(10, list.Count);
91+
var list2 = User.Context.InnerJoin<ArticleModel>("b", (a, b) => a.Id == b.Userid).OrderByDescing(f => f.Createtime).Page(1, 10).ToList<UserViewModel>("a.id,a.nickname,a.password");
92+
93+
Assert.Equal(10, list2.Count);
94+
}
95+
96+
public class UserViewModel
97+
{
98+
public string Id { get; set; }
99+
public string NickName { get; set; }
100+
public string Password { get; set; }
92101
}
93102

94103
[Fact]

MyStaging/Helpers/QueryContext.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,17 @@ void action(DbDataReader dr)
363363
TResult obj = default(TResult);
364364
Type objType = typeof(TResult);
365365
bool isTuple = objType.Namespace == "System" && objType.Name.StartsWith("ValueTuple`");
366+
bool isEnum = objType.IsEnum;
366367
if (isTuple)
367368
{
368369
int columnIndex = -1;
369370
obj = (TResult)GetValueTuple(objType, dr, ref columnIndex);
370371
}
371-
else if (IsValueType(objType))
372+
else if (IsValueType(objType) || isEnum)
372373
{
373374
obj = (TResult)GetValueType(objType, dr);
374375
}
375-
else if (objType.Namespace.StartsWith("Newtonsoft"))
376+
else if (objType.Namespace != null && objType.Namespace.StartsWith("Newtonsoft"))
376377
{
377378
obj = (TResult)GetJToken(dr);
378379
}

MyStaging/MyStaging.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Copyright>MIT</Copyright>
99
<PackageLicenseUrl>https://github.com/lianggx/mystaging/blob/master/LICENSE</PackageLicenseUrl>
1010
<PackageProjectUrl>https://github.com/lianggx/mystaging</PackageProjectUrl>
11-
<Version>1.0.7</Version>
11+
<Version>1.0.9</Version>
1212
<AssemblyVersion>1.0.7.0</AssemblyVersion>
1313
<FileVersion>1.0.7.0</FileVersion>
1414
<PackageReleaseNotes>增加 Update 和 Delete 操作的检查,当没有指定更新字段和 Where 条件时,将抛出异常,防止对整表的误操作</PackageReleaseNotes>

0 commit comments

Comments
 (0)