Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit a0c0070

Browse files
authored
Merge pull request #36 from linq2db/master
Release 3.0.0
2 parents 9a9a788 + acc96cc commit a0c0070

File tree

115 files changed

+10782
-10229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+10782
-10229
lines changed

Build/linq2db.Default.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>2.0.5</Version>
3+
<Version>3.0.0</Version>
44

55
<Description>Allows to execute Linq to DB (linq2db) queries in Entity Framework Core DbContext.</Description>
66
<Title>Linq to DB (linq2db) extensions for Entity Framework Core</Title>

NuGet/linq2db.EntityFrameworkCore.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<license type="file">MIT-LICENSE.txt</license>
1616
<dependencies>
1717
<group targetFramework=".NETStandard2.1">
18-
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="3.0.0" />
19-
<dependency id="linq2db" version="2.9.6" />
18+
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="3.1.3" />
19+
<dependency id="linq2db" version="3.0.0-preview.2" />
2020
</group>
2121
</dependencies>
2222
</metadata>

Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,15 @@ private Sql.ExpressionAttribute GetDbFunctionFromMethodCall(Type type, MethodInf
243243

244244
if (!methodInfo.IsGenericMethodDefinition && !mi.GetCustomAttributes<Sql.ExpressionAttribute>().Any())
245245
{
246-
var objExpr = new SqlTransparentExpression(Expression.Constant(DefaultValue.GetValue(type), type), _mappingSource.FindMapping(type));
246+
var value = Expression.Constant(DefaultValue.GetValue(type), type);
247+
248+
var objExpr = new SqlTransparentExpression(value, _mappingSource?.FindMapping(type));
247249
var parameterInfos = methodInfo.GetParameters();
248250
var parametersArray = parameterInfos
249251
.Select(p =>
250252
(SqlExpression)new SqlTransparentExpression(
251253
Expression.Constant(DefaultValue.GetValue(p.ParameterType), p.ParameterType),
252-
_mappingSource.FindMapping(p.ParameterType))).ToArray();
254+
_mappingSource?.FindMapping(p.ParameterType))).ToArray();
253255

254256
var newExpression = _dependencies.MethodCallTranslatorProvider.Translate(_model, objExpr, methodInfo, parametersArray);
255257
if (newExpression != null)
@@ -280,7 +282,7 @@ private Sql.ExpressionAttribute GetDbFunctionFromProperty(Type type, PropertyInf
280282

281283
if ((propInfo.GetMethod?.IsStatic != true) && !mi.GetCustomAttributes<Sql.ExpressionAttribute>().Any())
282284
{
283-
var objExpr = new SqlTransparentExpression(Expression.Constant(DefaultValue.GetValue(type), type), _mappingSource.FindMapping(propInfo));
285+
var objExpr = new SqlTransparentExpression(Expression.Constant(DefaultValue.GetValue(type), type), _mappingSource?.FindMapping(propInfo));
284286

285287
var newExpression = _dependencies.MemberTranslatorProvider.Translate(objExpr, propInfo, propInfo.GetMemberType());
286288
if (newExpression != null)

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ static bool InitializeInternal()
7575

7676
LinqExtensions.ExtensionsAdapter = new LinqToDBExtensionsAdapter();
7777

78+
// Set linq2db to allow multiple queries by default
79+
Common.Configuration.Linq.AllowMultipleQuery = true;
80+
7881
return true;
7982
}
8083

@@ -262,18 +265,20 @@ public static DataConnection CreateLinqToDbConnection(this DbContext context,
262265
if (transaction != null)
263266
{
264267
var dbTrasaction = transaction.GetDbTransaction();
265-
if (provider.IsCompatibleConnection(dbTrasaction.Connection))
268+
// TODO: we need API for testing current connection
269+
//if (provider.IsCompatibleConnection(dbTrasaction.Connection))
266270
dc = new LinqToDBForEFToolsDataConnection(context, provider, dbTrasaction, context.Model, TransformExpression);
267271
}
268272

269273
if (dc == null)
270274
{
271275
var dbConnection = context.Database.GetDbConnection();
272-
if (provider.IsCompatibleConnection(dbConnection))
276+
// TODO: we need API for testing current connection
277+
if (true /*provider.IsCompatibleConnection(dbConnection)*/)
273278
dc = new LinqToDBForEFToolsDataConnection(context, provider, dbConnection, context.Model, TransformExpression);
274279
else
275280
{
276-
dc = new LinqToDBForEFToolsDataConnection(context, provider, connectionInfo.ConnectionString, context.Model, TransformExpression);
281+
//dc = new LinqToDBForEFToolsDataConnection(context, provider, connectionInfo.ConnectionString, context.Model, TransformExpression);
277282
}
278283
}
279284

@@ -318,17 +323,21 @@ public static IDataContext CreateLinqToDbContext(this DbContext context,
318323
if (transaction != null)
319324
{
320325
var dbTransaction = transaction.GetDbTransaction();
321-
if (provider.IsCompatibleConnection(dbTransaction.Connection))
322-
dc = new LinqToDBForEFToolsDataConnection(context, provider, dbTransaction, context.Model, TransformExpression);
326+
327+
// TODO: we need API for testing current connection
328+
// if (provider.IsCompatibleConnection(dbTransaction.Connection))
329+
dc = new LinqToDBForEFToolsDataConnection(context, provider, dbTransaction, context.Model, TransformExpression);
323330
}
324331

325332
if (dc == null)
326333
{
327334
var dbConnection = context.Database.GetDbConnection();
328-
if (provider.IsCompatibleConnection(dbConnection))
335+
// TODO: we need API for testing current connection
336+
if (true /*provider.IsCompatibleConnection(dbConnection)*/)
329337
dc = new LinqToDBForEFToolsDataConnection(context, provider, context.Database.GetDbConnection(), context.Model, TransformExpression);
330338
else
331339
{
340+
/*
332341
// special case when we have to create data connection by itself
333342
var dataContext = new LinqToDBForEFToolsDataContext(context, provider, connectionInfo.ConnectionString, context.Model, TransformExpression);
334343
@@ -339,6 +348,7 @@ public static IDataContext CreateLinqToDbContext(this DbContext context,
339348
dataContext.OnTraceConnection = t => Implementation.LogConnectionTrace(t, logger);
340349
341350
return dataContext;
351+
*/
342352
}
343353
}
344354

0 commit comments

Comments
 (0)