Skip to content

Commit 0bb261b

Browse files
committed
#53 get the package ready for release
1 parent b30a833 commit 0bb261b

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

SubSonic.Core.DataAccessLayer/SubSonic.Core.DataAccessLayer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.6" />
5858
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.6" />
5959
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.6" />
60-
<PackageReference Include="SubSonic.Core.Abstractions" Version="4.2.0-beta.4" />
60+
<PackageReference Include="SubSonic.Core.Abstractions" Version="4.2.0" />
6161
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
6262
<PackageReference Include="System.Data.Common" Version="4.3.0" />
6363
<PackageReference Condition="'$(TargetFramework)'=='netstandard2.0'" Include="System.Data.DataSetExtensions" Version="4.5.0" />

SubSonic.Core.DataAccessLayer/src/Builders/DbNavigationPropertyBuilder.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ private string[] GetForeignKeys(Type type)
119119

120120
private string[] GetForeignKeys(Expression expression)
121121
{
122-
if(expression.IsNotNull())
122+
if(expression is MemberExpression TheMember)
123123
{
124-
return Ext.GetForeignKeyName((PropertyInfo)((MemberExpression)expression).Member);
124+
if (TheMember.Member is PropertyInfo property)
125+
{
126+
return Ext.GetForeignKeyName(property);
127+
}
125128
}
126129
return Array.Empty<string>();
127130
}

SubSonic.Core.DataAccessLayer/src/Builders/DbSqlQueryBuilder/DbSqlQueryBuilderBuildMethods.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ public Expression BuildSelect(MethodCallExpression call)
7373

7474
if (!(predicate is null))
7575
{
76+
#if NETSTANDARD2_0
7677
method = method ?? typeof(Queryable).GetGenericMethod(nameof(Queryable.Where),
77-
new[] { DbTable.Type.GenericTypeArguments[0] },
78+
#elif NETSTANDARD2_1
79+
method ??= typeof(Queryable).GetGenericMethod(nameof(Queryable.Where),
80+
#endif
81+
new[] { DbTable.Type.GenericTypeArguments[0] },
7882
DbTable.Type,
7983
predicate.GetType());
8084

@@ -186,9 +190,9 @@ private Expression BuildSelect(Expression expression, IEnumerable<DbColumnDeclar
186190

187191
return expression;
188192
}
189-
#endregion
193+
#endregion
190194

191-
#region Build Where
195+
#region Build Where
192196
public Expression BuildWhere(DbExpression expression, LambdaExpression predicate)
193197
{
194198
if (expression is null)
@@ -229,9 +233,9 @@ public Expression BuildWhereFindByIDPredicate(DbExpression expression, object[]
229233

230234
return BuildWhere(expression, predicate);
231235
}
232-
#endregion
236+
#endregion
233237

234-
#region Build Joins
238+
#region Build Joins
235239
public Expression BuildJoin(JoinType type, Expression left, Expression right)
236240
{
237241
if (left is DbSelectExpression select)
@@ -252,9 +256,9 @@ public Expression BuildJoin(JoinType type, Expression left, Expression right)
252256

253257
throw new NotSupportedException();
254258
}
255-
#endregion
259+
#endregion
256260

257-
#region Lambda
261+
#region Lambda
258262
public Expression BuildLambda(Expression body, LambdaType @call, params string[] properties)
259263
{
260264
switch (call)
@@ -370,7 +374,7 @@ public Expression BuildLogicalBinary(Expression body, string property, object va
370374
return DbWherePredicateBuilder.GetBodyExpression(body, DbWherePredicateBuilder.GetComparisonExpression(left, right, @operator), @group);
371375
}
372376
}
373-
#endregion
377+
#endregion
374378

375379
public IDbQuery ToQuery(Expression expression)
376380
{

SubSonic.Core.DataAccessLayer/src/Extensions/Internal/DatabaseReaders.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public static object LoadInstanceOf(this IDataRecord data, object entity)
3131
}
3232
}
3333

34-
if (entity is IEntityProxy)
34+
if (entity is IEntityProxy proxy)
3535
{
36-
((IEntityProxy)entity).IsNew = false;
37-
((IEntityProxy)entity).IsDirty = false;
36+
proxy.IsNew = false;
37+
proxy.IsDirty = false;
3838
}
3939

4040
return entity;
@@ -51,8 +51,7 @@ public static object ActivateAndLoadInstanceOf(this IDataRecord data, Type entit
5151
throw new ArgumentNullException(nameof(data));
5252
}
5353

54-
object entity = null;
55-
54+
object entity;
5655
if (SubSonicContext.DbOptions.EnableProxyGeneration &&
5756
SubSonicContext.DbModel.IsEntityModelRegistered(entityType))
5857
{

SubSonic.Core.DataAccessLayer/src/Schema/DbRelationshipMap.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public IEnumerable<string> GetForeignKeys(IDbEntityModel entityModel)
5151
{
5252
if (RelationshipType == DbRelationshipType.HasManyWithMany)
5353
{
54+
if (entityModel is null)
55+
{
56+
throw Error.ArgumentNull(nameof(entityModel));
57+
}
58+
5459
PropertyInfo property = IsLookupMapping
5560
? LookupModel.EntityModelType.GetProperty(entityModel.Name)
5661
: ForeignModel.EntityModelType.GetProperty(ForeignModel.Name);

SubSonic.Tests/SubSonic.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2121
</PackageReference>
2222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
23-
<PackageReference Include="SubSonic.Core.Abstractions" Version="4.2.0-beta.4" />
23+
<PackageReference Include="SubSonic.Core.Abstractions" Version="4.2.0" />
2424
<PackageReference Include="SubSonic.Extensions.SqlServer" Version="4.2.0" />
25-
<PackageReference Include="SubSonic.Extensions.Test" Version="4.2.1-beta.6" />
25+
<PackageReference Include="SubSonic.Extensions.Test" Version="4.2.1" />
2626
</ItemGroup>
2727

2828
<ItemGroup>

0 commit comments

Comments
 (0)