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

Commit c02796b

Browse files
authored
Fix for #132. Removed arrays from automatic conversion. (#138)
* Fix for #132. Removed arrays from automatic conversion. * Fixed compiler warnings.
1 parent a23793f commit c02796b

File tree

6 files changed

+44
-1
lines changed

6 files changed

+44
-1
lines changed

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@ public virtual void DefineConvertors(
455455
if (modelType.IsEnum)
456456
continue;
457457

458+
// skipping arrays
459+
if (modelType.IsArray)
460+
continue;
461+
458462
MapEFCoreType(modelType);
459463
if (modelType.IsValueType && !typeof(Nullable<>).IsSameOrParentOf(modelType))
460464
MapEFCoreType(typeof(Nullable<>).MakeGenericType(modelType));

Tests/LinqToDB.EntityFrameworkCore.BaseTests/Logging/TestLogger.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ internal class TestLogger : ILogger
1313
private static readonly string _newLineWithMessagePadding;
1414

1515
// ConsoleColor does not have a value to specify the 'Default' color
16+
#pragma warning disable 649
1617
private readonly ConsoleColor? DefaultConsoleColor;
18+
#pragma warning restore 649
1719

1820
private readonly string _name;
1921

Tests/LinqToDB.EntityFrameworkCore.BaseTests/TestUtils.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class TestUtils
1515

1616
.AddTestLogger(o =>
1717
{
18-
o.IncludeScopes = true;
1918
o.FormatterName = ConsoleFormatterNames.Simple;
2019
});
2120
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.ComponentModel.DataAnnotations;
3+
4+
namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.NpgSqlEntities
5+
{
6+
public class EntityWithArrays
7+
{
8+
[Key]
9+
public int Id { get; set; }
10+
11+
public Guid[] Guids { get; set; } = null!;
12+
}
13+
}

Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
2020
entity.HasNoKey();
2121
entity.ToView("EventsView", "views");
2222
});
23+
24+
modelBuilder.Entity<EntityWithArrays>(entity =>
25+
{
26+
});
2327
}
2428

2529
public virtual DbSet<Event> Events { get; set; } = null!;
30+
public virtual DbSet<EntityWithArrays> EntityWithArrays { get; set; } = null!;
2631

2732
}
2833
}

Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Linq;
3+
using FluentAssertions;
34
using LinqToDB.Data;
5+
using LinqToDB.DataProvider.PostgreSQL;
46
using LinqToDB.EntityFrameworkCore.BaseTests;
57
using LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.NpgSqlEntities;
68
using Microsoft.EntityFrameworkCore;
@@ -67,5 +69,23 @@ public void TestViewMapping()
6769
var l2dbResult = query.ToLinqToDB().ToArray();
6870
}
6971
}
72+
73+
[Test]
74+
public void TestArray()
75+
{
76+
using (var db = CreateNpgSqlEntitiesContext())
77+
{
78+
var guids = new Guid[] { Guid.Parse("271425b1-ebe8-400d-b71d-a6e47a460ae3"),
79+
Guid.Parse("b75de94e-6d7b-4c70-bfa1-f8639a6a5b35") };
80+
81+
var query =
82+
from m in db.EntityWithArrays.ToLinqToDBTable()
83+
where Sql.Ext.PostgreSQL().Overlaps(m.Guids, guids)
84+
select m;
85+
86+
query.Invoking(q => q.ToArray()).Should().NotThrow();
87+
}
88+
}
89+
7090
}
7191
}

0 commit comments

Comments
 (0)