Can't map an entity type's inherited properties

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
ruslan.net
Posts: 8
Joined: Wed 31 Oct 2012 12:53

Can't map an entity type's inherited properties

Post by ruslan.net » Sat 17 Nov 2012 08:35

In continuation of this topic: http://forums.devart.com/viewtopic.php?f=31&t=25170
Let's assume that I have a DB table "Orders" with columns "Id", "StateCode" and "OrderDate". (Most tables in my database have an "Id" column and some of those have a "StateCode" column)

All I want is an enitity stucture like this:

Code: Select all

abstract class EntityWithId
{
  public int Id { get; set; }
}
abstract class EntityWithState : EntityWithId
{
  public string StateCode { get; set; }
}
class Order : EntityWithState
{
  public DateTime Date { get; set; }
}
The Fluent mapping allows me to configure the inherited properties while mapping an "Order" class but a DataContext doesn't query them and the XML mapping can't even create a MappingSource :(

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Can't map an entity type's inherited properties

Post by MariiaI » Mon 19 Nov 2012 15:18

Could you please provide us with a sample project, that demonstrates the issues that you have encountered, including the mapping file you are working with, the definition of the entity classes (both for Fluent and XML mapping).
Also, please specify whether you are getting any errors when performing your scenario? If yes, please tell us their text and specify the stack traces.

ruslan.net
Posts: 8
Joined: Wed 31 Oct 2012 12:53

Re: Can't map an entity type's inherited properties

Post by ruslan.net » Tue 20 Nov 2012 07:52

I've sent a simplified project with an XML mapping.

I get a NotSupportedException "Mapped member had no corresponding member in type No. ClosingDoc" in a DataContext constructor.

StackTrace:
at Devart.Data.Linq.Mapping.o.c(MetaType A_0, Object A_1)
at Devart.Data.Linq.Mapping.q.a(MetaTable A_0, Type A_1, Object A_2, Object A_3)
at Devart.Data.Linq.Mapping.q.f(Type A_0, Object A_1)
at Devart.Data.Linq.Mapping.q.e(Type A_0, Object A_1)
at Devart.Data.Linq.Mapping.o.d()
at Devart.Data.Linq.Mapping.q.h()
at Devart.Data.Linq.Mapping.MappingSource.a(Type A_0)
at Devart.Data.Linq.Mapping.MappingSource.GetModel(Type dataContextType)
at Devart.Data.Linq.DataContext.a(Object A_0, MappingSource A_1, Type A_2)
at Devart.Data.Linq.DataContext..ctor(IDbConnection connection, MappingSource mapping)
at XMLMapping.MyDC..ctor(OracleConnection conn, XmlMappingSource source) in C:\Users\ruslan\Desktop\XMLMapping\XMLMapping\Program.cs:line 12
at XMLMapping.Program.Main(String[] args) in C:\Users\ruslan\Desktop\XMLMapping\XMLMapping\Program.cs:line 40
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
The InnerException is null.

When I move the "No" property from the base class "EntityWithNo" to the "ClosingDoc", the sample becomes operational.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Can't map an entity type's inherited properties

Post by MariiaI » Wed 21 Nov 2012 08:21

Thank you for the sample project. We have reproduced this issue. We will investigate it and inform you about the results as soon as possible.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Can't map an entity type's inherited properties

Post by MariiaI » Mon 20 May 2013 05:35

The bug with inheriting an entity class from an unmapped type is fixed.
New build of LinqConnect 4.2.247 is available for download now!
It can be downloaded from http://www.devart.com/linqconnect/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=31&t=27137.

Post Reply