New Posts New Posts RSS Feed: Two entities using the same database table
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Two entities using the same database table

 Post Reply Post Reply
Author
Peter View Drop Down
Newbie
Newbie


Joined: 14-Jun-2010
Posts: 7
Post Options Post Options   Quote Peter Quote  Post ReplyReply Direct Link To This Post Topic: Two entities using the same database table
    Posted: 13-Jul-2010 at 7:46am

For anyone who is intressed.

De EF inheritance type TPH is working in this situation, as I described before.
The problem was (still is), that not in all cases the Visual Studio 2010 IDE correctly updated my EDMX file.
When I deleted an, automatic generated assiocation, the XML tag was not deleted in  the EDMX file.
I had to do it by manually.
I've read about this on the internet but I'm not sure if this is a bug or a local problem.
 
 
 
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 22-Jun-2010 at 7:58pm
Hi Peter,
 
Yes, I forgot about that possibility.  That's seems like a reasonable approach.
 
 
Back to Top
Peter View Drop Down
Newbie
Newbie


Joined: 14-Jun-2010
Posts: 7
Post Options Post Options   Quote Peter Quote  Post ReplyReply Direct Link To This Post Posted: 17-Jun-2010 at 2:18am

Hello ting,

 

Thank for your response.

I also believe it is a EF question.

But, I find it hard to believe that I need to solve this though one entity.

 

I've read so far:

 

I can define two EF entities and alter the mapping properties.

The mapping properties also can hold conditions to filter the query.

Within my own partial class of Directory and File I can set the 'IsFile' variable.

 

I'm still testing this approche  

I’ll  keep you posted.

Peter

Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 15-Jun-2010 at 8:19pm
Yes, this is more of an Entity Framework question, but it is interesting nonetheless.  I'm not the modelling expert, but I suspect that you will need to unify the DirectoryEntity and FileEntity into a single entity and return empty collections when IsFile is true.  You can make the foreign key fields private/protected (not a bad practice) so that everyone goes through the object-oriented methods.
Back to Top
Peter View Drop Down
Newbie
Newbie


Joined: 14-Jun-2010
Posts: 7
Post Options Post Options   Quote Peter Quote  Post ReplyReply Direct Link To This Post Posted: 14-Jun-2010 at 4:06am

Ok, I just hit the wrong button.. lets resume my post.

Hello,
 
I've just started with DevForce and have a question about modelling my entities.
I'm not sure where EF ends and DF begins, so this may be an EF question.
 
I have a classic 'directory-file' situation
On one side the directory tree and on the other the containing files
I'm using one table to store these instances.

DataTable
- ID  Int
- Name  Varchar
- IsFile Bit
- Parent_ID  Int

DirectoryEntity
- ID  Int
- Name  String
- Parent  DirectoryEntity
- Childs Collection of DirectoryEntiry
- Files  Collection of FileEntity

FileEntity
- ID  Int
- Name  String
- Parent DirectoryEntity

Questions:
1. What is the best way to implement this?
2. How do I hide 'IsFile', but, implement it's value in the correct entity class?
3. EF, by default, makes FK fields public, like 'Parent_ID'. Can I freely set it getter and setter to private?

Thank in advance.
Peter

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down