diff --git a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs index fa22507..b60cbfc 100644 --- a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs +++ b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs @@ -450,6 +450,10 @@ public virtual void DefineConvertors( if (modelType.IsEnum) continue; + // skipping arrays + if (modelType.IsArray) + continue; + MapEFCoreType(modelType); if (modelType.IsValueType && !typeof(Nullable<>).IsSameOrParentOf(modelType)) MapEFCoreType(typeof(Nullable<>).MakeGenericType(modelType)); diff --git a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/EntityWithArrays.cs b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/EntityWithArrays.cs new file mode 100644 index 0000000..33f0b2a --- /dev/null +++ b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/EntityWithArrays.cs @@ -0,0 +1,13 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.NpgSqlEntities +{ + public class EntityWithArrays + { + [Key] + public int Id { get; set; } + + public Guid[] Guids { get; set; } = null!; + } +} diff --git a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs index c02c2d4..45e90b9 100644 --- a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs +++ b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs @@ -20,9 +20,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.HasNoKey(); entity.ToView("EventsView", "views"); }); + + modelBuilder.Entity(entity => + { + }); } public virtual DbSet Events { get; set; } = null!; + public virtual DbSet EntityWithArrays { get; set; } = null!; } } diff --git a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs index 58fda4d..18e885d 100644 --- a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs +++ b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs @@ -1,6 +1,8 @@ using System; using System.Linq; +using FluentAssertions; using LinqToDB.Data; +using LinqToDB.DataProvider.PostgreSQL; using LinqToDB.EntityFrameworkCore.BaseTests; using LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.NpgSqlEntities; using Microsoft.EntityFrameworkCore; @@ -54,6 +56,35 @@ public void TestFunctionsMapping() } } - + [Test] + public void TestViewMapping() + { + using (var db = CreateNpgSqlEntitiesContext()) + { + var query = db.Set().Where(e => + e.Name.StartsWith("any")); + + var efResult = query.ToArray(); + var l2dbResult = query.ToLinqToDB().ToArray(); + } + } + + [Test] + public void TestArray() + { + using (var db = CreateNpgSqlEntitiesContext()) + { + var guids = new Guid[] { Guid.Parse("271425b1-ebe8-400d-b71d-a6e47a460ae3"), + Guid.Parse("b75de94e-6d7b-4c70-bfa1-f8639a6a5b35") }; + + var query = + from m in db.EntityWithArrays.ToLinqToDBTable() + where Sql.Ext.PostgreSQL().Overlaps(m.Guids, guids) + select m; + + query.Invoking(q => q.ToArray()).Should().NotThrow(); + } + } + } }