UnmappedClassMember

UnmappedClassMember

Postby hepek » Tue 14 May 2013 15:13

I have entity called "OplHistory", and I have partial class like this(added two properties):
Code: Select all
partial class OplHistory {
   public string ModifiedByName { get; set; }
   public string ModifiedBySite { get; set; }
}

my Get method looks like this:
Code: Select all
using System.Linq;
using Devart.Data.Oracle;
usig System.Data.Common;

public List<OplHistory> GetWoHistory(long dealNum, long jobNum, long cycleNum) {
      var query = from hist in DB.OplHistories
                  join emp in DB.Employees on hist.ModifyEmpId equals emp.EmployeeId
                  join site in DB.Sites on hist.ModifySiteId equals site.SiteId
                  where hist.DealNumber == dealNum &&
                        hist.JobNumber == jobNum &&
                        hist.CycleNumber == cycleNum
                  select new OplHistory {
                     ModifyColumn = hist.ModifyColumn,
                     OldValue = hist.OldValue,
                     NewValue = hist.NewValue,
                     ModifiedByName = emp.NameFirst + " " + emp.NameLast,
                     ModifiedBySite = site.NameShort
                  };
   return query.ToList();
}


when I call GetWoHistory method I get exception:
Code: Select all
UnmappedClassMember OplHistory, ModifiedByName. source: Devart.Data.Linq
Last edited by hepek on Tue 14 May 2013 15:21, edited 4 times in total.
hepek
 
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: UnmappedClassMember

Postby hepek » Tue 14 May 2013 15:15

this code works ok with dotConnect version 6.7.
with version 7.7 I get the exception.

here is the whole stack trace:
Code: Select all
at Devart.Data.Linq.Engine.h.a(MemberInitExpression A_0)
   at Devart.Data.Linq.Engine.h.j(Expression A_0)
   at Devart.Data.Linq.Engine.h.d(Expression A_0, Expression A_1)
   at Devart.Data.Linq.Engine.h.b(MethodCallExpression A_0)
   at Devart.Data.Linq.Engine.h.j(Expression A_0)
   at Devart.Data.Linq.Engine.h.i(Expression A_0)
   at Devart.Data.Linq.Engine.do.d(Expression A_0)
   at Devart.Data.Linq.Engine.do.f(Expression A_0)
   at Devart.Data.Linq.Engine.DataQuery`1.h()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at RRD.OnePlace.BLL.CycleBO.GetWoHistory(Int64 dealNum, Int64 jobNum, Int64 cycleNum) in C:\OnePlace\WebSite\RRD.OnePlace.BLL\CycleBO.cs:line 1213
   at RRD.OnePlace.WEB.Popups.WorkOrderHistory.Page_Load(Object sender, EventArgs e) in C:\OnePlace\WebSite\RRD.OnePlace.WEB\Popups\WorkOrderHistory.aspx.cs:line 15
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at RRD.OnePlace.WEB.BasePage.OnLoad(EventArgs e) in C:\OnePlace\WebSite\RRD.OnePlace.WEB\AppClasses\BasePage.cs:line 61
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
hepek
 
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: UnmappedClassMember

Postby MariiaI » Mon 20 May 2013 05:26

Thank you for the test project. The issue is that your partial class 'OplHistory' has the same name as an entity class 'OplHistory', which is mapped to a database table. When you try executing the query you get the error because LinqConnect recognize properties 'ModifiedByName' and 'ModifiedBySite' of the extended class 'OplHistory' as properties of an entity class 'OplHistory' and assume that that they should be mapped too.
The best solution for you is to implement an inherited class from the 'OplHistory' entity class, e.g.:
Code: Select all
public partial class OplHistory_inherited : OplHistory
    {
      public string ModifiedByName { get; set; }
      public string ModifiedBySite { get; set; }
   }

Please, rewrite your GetWoHistory method in the following way:
Code: Select all
static List<OplHistory_inherited> GetWoHistory(long jobNum, long cycleNum) {
         var query = from hist in DB.OplHistories
                     join emp in DB.Employees on hist.ModifyEmpId equals emp.EmployeeId
                     where hist.JobNumber == jobNum &&
                           hist.CycleNumber == cycleNum
                     select new OplHistory_inherited {
                        JobNumber = hist.JobNumber,
                        ModifiedByName = emp.NameFirst + " " + emp.NameLast,
                     };
         return query.ToList();
      }

We have sent your modified project back to you.
Please tell us if this helps.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: UnmappedClassMember

Postby hepek » Mon 20 May 2013 16:32

thank you MariiaI

But I don't want to inherit, I want to be able to use partial class feature. As a mater of fact, I don't want to change my code because new version of dotConnect.
I have had that code for years and never had problem with it until I installed dotConnect version 7.

This technique to use partial classes in order to extend functionality or add properties is very commonly used. Also makes a lot of sense. Developers do this all the time - they would create a partial class in order to add extra property to a class generated by Devart.

I have partial classes in many places in my app. The only difference is this one place where it gives me trouble I am using a LINQ query expression rather then Lambda expression.
So, LinqConnect does support partial classes and creating properties without any column mapping.

thank you
Last edited by hepek on Tue 21 May 2013 16:39, edited 1 time in total.
hepek
 
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: UnmappedClassMember

Postby MariiaI » Tue 21 May 2013 12:04

We will investigate the differences in behavior when implementing this scenario in the 6 and 7 versions of dotConnect for Oracle. We will inform you about the results as soon as possible.
As a workaround, please use the inheritance approach, which is described above.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: UnmappedClassMember

Postby MariiaI » Wed 22 May 2013 09:42

We have changed the behavior related to the UnmappedClassMember exception. The fix will be included in the next build of dotConnect for Oracle. We will inform you when it is available for download.
Also, we can send you an intermediate build with the fix, which we will prepare in several days. Please specify us your license number for this.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: UnmappedClassMember

Postby hepek » Wed 22 May 2013 13:45

I will wait until regular build is out. I found a way around this problem for now.

thank you
hepek
 
Posts: 115
Joined: Thu 07 Jul 2011 13:59

Re: UnmappedClassMember

Postby MariiaI » Thu 23 May 2013 07:19

We will necessarily inform you when the new build of dotConnect for Oracle is available for download.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: UnmappedClassMember

Postby MariiaI » Fri 31 May 2013 06:39

New build of dotConnect for Oracle 7.7.252 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/oracle/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=1&t=27239.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: UnmappedClassMember

Postby hepek » Fri 31 May 2013 21:30

thank you
hepek
 
Posts: 115
Joined: Thu 07 Jul 2011 13:59


Return to dotConnect for Oracle