EntityFramework-Extensions icon indicating copy to clipboard operation
EntityFramework-Extensions copied to clipboard

WhereBulkContains does not work when table inherit from another table

Open lyk2016 opened this issue 3 months ago • 1 comments

Description

WhereBulkContains does not work when database table inherit from another database table

Exception

Exception message:An error occurred while executing the command definition. See the inner exception for details.
InnerException:Oops! Untyped list is not compatible with multiple inheritance entity type (TPC, TPH, TPT).
Stack trace:   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass41_0.<GetResults>b__0()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__31_0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

Fiddle or Project (Optional)

sample code as below(C#)

       public class TableA//table a
        {
            public int ID { get; set; }
            public int V2 { get; set; }
        }
        public class TableB : TableA//table b inherit table a
        {
            public int V3 { get; set; }
        }

        public void test()
        {
            List<int> ids = new List<int>() { 1, 2, 3 };
            using (DBContext db = new DBContext())
            {
                var q = db.TableB.WhereBulkContains(ids, r => r.ID).ToList();//error here
            }
        }

Further technical details

  • EF Extensions version: [v4.0.30319]
  • Database Server version: [SQL Server 2019]

I appreciate your help.

lyk2016 avatar Apr 19 '24 08:04 lyk2016

Hello @lyk2016 ,

Indeed the WhereBulkContains doesn't support inheritance yet.

I do not believe it will be ever supported for EF6 and below.

Best Regards,

Jon

JonathanMagnan avatar Apr 19 '24 14:04 JonathanMagnan