This repository was archived by the owner on Feb 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +54
-1
lines changed
Source/LinqToDB.EntityFrameworkCore
Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,10 @@ public virtual void DefineConvertors(
450450 if ( modelType . IsEnum )
451451 continue ;
452452
453+ // skipping arrays
454+ if ( modelType . IsArray )
455+ continue ;
456+
453457 MapEFCoreType ( modelType ) ;
454458 if ( modelType . IsValueType && ! typeof ( Nullable < > ) . IsSameOrParentOf ( modelType ) )
455459 MapEFCoreType ( typeof ( Nullable < > ) . MakeGenericType ( modelType ) ) ;
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 11using System ;
22using System . Linq ;
3+ using FluentAssertions ;
34using LinqToDB . Data ;
5+ using LinqToDB . DataProvider . PostgreSQL ;
46using LinqToDB . EntityFrameworkCore . BaseTests ;
57using LinqToDB . EntityFrameworkCore . PostgreSQL . Tests . Models . NpgSqlEntities ;
68using Microsoft . EntityFrameworkCore ;
@@ -54,6 +56,35 @@ public void TestFunctionsMapping()
5456 }
5557 }
5658
57-
59+ [ Test ]
60+ public void TestViewMapping ( )
61+ {
62+ using ( var db = CreateNpgSqlEntitiesContext ( ) )
63+ {
64+ var query = db . Set < EventView > ( ) . Where ( e =>
65+ e . Name . StartsWith ( "any" ) ) ;
66+
67+ var efResult = query . ToArray ( ) ;
68+ var l2dbResult = query . ToLinqToDB ( ) . ToArray ( ) ;
69+ }
70+ }
71+
72+ [ Test ]
73+ public void TestArray ( )
74+ {
75+ using ( var db = CreateNpgSqlEntitiesContext ( ) )
76+ {
77+ var guids = new Guid [ ] { Guid . Parse ( "271425b1-ebe8-400d-b71d-a6e47a460ae3" ) ,
78+ Guid . Parse ( "b75de94e-6d7b-4c70-bfa1-f8639a6a5b35" ) } ;
79+
80+ var query =
81+ from m in db . EntityWithArrays . ToLinqToDBTable ( )
82+ where Sql . Ext . PostgreSQL ( ) . Overlaps ( m . Guids , guids )
83+ select m ;
84+
85+ query . Invoking ( q => q . ToArray ( ) ) . Should ( ) . NotThrow ( ) ;
86+ }
87+ }
88+
5889 }
5990}
You can’t perform that action at this time.
0 commit comments