cannot access some classes in Type per Table inheritance?

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Lyu_KingT
Posts: 7
Joined: Thu 21 Oct 2010 06:08

cannot access some classes in Type per Table inheritance?

Post by Lyu_KingT » Thu 18 Nov 2010 09:11

0. i generated a model form Oracle with dotConnect,
1. i created a base class name ClinicObject, because a few of tables in DBMS contained same columns. so i want to derive them from ClinicObject (see following link: Screen-Snap Link 1).
2. i finished the derived relationship (Type per Table).
some of derived class do not have any property else except the properties from the BaseClass (ClinicObject) for instance:

Code: Select all

   
public DeriveClass : ClinicObject
{}


3. but i found some questions in Context:
there is no AddToDeriveClass(), instead, there is only AddToClinicObject() in Context;
there is no property of Context named DeriveClass, so i cannot access the ObjectSet by using Context.DeriveClass
i can insert DeriveClass, but i cannot update or delete, and i found that when i try to query the Context.ClinicObject, a Exception in which there is a innerException named Devart.Data.Oracle.OracleException,
and ORA-01790 occurred!
(See Screen-Snap Link 2)

so how to access (query, update, delete) this special derivedClasses?

thx.

Screen-Snap Link 1

Screen-Snap Link 2

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 18 Nov 2010 13:06

Most of the issues are associated with the fact that we provide support for only one EntitySet per hierarchy, like Microsoft does.
We will investigate the possibity of adding support for multiple EntitySets, one for each hierarchy member.
Try using the explicit cast to the base class to modify the entities of the derived class.
As for the ORA-01790 error, please try adding the Devart.Data.Oracle.Entity.OracleEntityProviderServices.TypedNulls = true; line to the OnCreated partial method of the ObjectContext instance.

Lyu_KingT
Posts: 7
Joined: Thu 21 Oct 2010 06:08

Post by Lyu_KingT » Wed 24 Nov 2010 02:35

AndreyR wrote:Most of the issues are associated with the fact that we provide support for only one EntitySet per hierarchy, like Microsoft does.
We will investigate the possibity of adding support for multiple EntitySets, one for each hierarchy member.
Try using the explicit cast to the base class to modify the entities of the derived class.
As for the ORA-01790 error, please try adding the Devart.Data.Oracle.Entity.OracleEntityProviderServices.TypedNulls = true; line to the OnCreated partial method of the ObjectContext instance.
i have solved the ORA-01790 problem following your suggestion. and i want to ask about the deployment.
the solution of ORA-01790 should refer the Devar.Date.dll adn Devart.Date.Oracle.dll (set Copy Local = true), so when i finished the application building, how to deploy the two dll files on client computer? just simply copy the two dll files?
and the more important thing is that is there limited time for the dll files?
thx.



as for the following words:
Try using the explicit cast to the base class to modify the entities of the derived class.
i finally did the UPDATE or DELETE by ObjectContext.SaveChanges() of my model in which, as i said, there are some derived classes are just derived from baseClass (they had no more properties else).
however, the success of SaveChanges() i monitored by dbMonitor is that, the two coding ways ware different:

Code: Select all

var query = .......;
var obj = query.First();
obj = entityWithNewData;    // the obj is a same class  as entityWithNewData

context.SaveChanges();   // there is no change because there seems be no UPDATE statement in dbMonitor

Code: Select all

var query = .......;
var obj = query.First();

// the obj is a same class  as entityWithNewData
obj.Name=entityWithNewData.Name;
obj.Code=entityWithNewData.Code;
// ... obj.Property = entityWithNewData.SameProperty

context.SaveChanges();  // the context is really changed!
so is this the only way to change the context for update? i mean if i have many many classes, there would be many many

Code: Select all

obj.Property1 = entityWithNewData.Property1;
// 2=2;
// 3=3;
// ....

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 24 Nov 2010 16:48

Actually, in the first snippet you are just setting the obj reference to an entity that is not attached to the context, so the ObjectContext instance is not aware that any changes were persisted, and does not make any updates.
In the second snippet you perform an explicit assignment of the properties, obj carries a tracked object with changed properties and everything works OK.
Try to Attach the detached entity instead:

Code: Select all

context.Attach(entityWithNewData);
context.ObjectStateManager.ChangeObjectState(entityWithNewData, System.Data.EntityState.Modified);
context.SaveChanges();

Lyu_KingT
Posts: 7
Joined: Thu 21 Oct 2010 06:08

Post by Lyu_KingT » Thu 25 Nov 2010 01:56

AndreyR wrote:Actually, in the first snippet you are just setting the obj reference to ...
thx, i'll try later.

However, i have asked you two question in last post, the another is:
...i want to ask about the deployment.
the solution of ORA-01790 should refer the Devar.Date.dll and Devart.Date.Oracle.dll (set Copy Local = true), so when i finished the application building, how to deploy the two dll files on client computer? just simply copy the two dll files?
and the more important thing is that is there limited time for the dll files on client computer?
thx.
best wishes

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 25 Nov 2010 09:33

Copy Devart.Data.dll, Devart.Data.Oracle.dll, and Devart.Data.Oracle.Entity.dll (it is necessary for EF projects) to the Bin folder of the deployed application.
There are no limitations on the usage time of the deployed solution.
You also need to register the provider in the application configuration file like in the following example:

Code: Select all


  
    
    
  

More details about deployment are available here.

Post Reply