No you cannot As explained by this article EF (3.5) does not support this feature. You must use stored procedure to accomplish this.
No you cannot. As explained by this article, EF (3.5) does not support this feature. You must use stored procedure to accomplish this.
It seems wrong that you have two tables representing users. Would it not be better to have a Users table (for all users) and then a UserPrivileges table, representing what they are allowed to do? This way, no deletes/Inserts are needed, and you can reference just one table for users.
A third table can be used to represent the actual privileges. Users Id Username ... UserPrivileges UserId PrivilegeId Privileges Id Description.
1 This is correct. An instance should/can never change type. So what happens when a user becomes privileged or non-privileged?
– Craig Stuntz Aug 6 '09 at 15:20 @Craig, any news? I ran into the same question. – Shimmy Jan 23 at 3:01 @Shimmy, "news?"
What news? If you think your object needs to change type, then you are probably misusing inheritance. @DanDan's answer is still a better idea.
– Craig Stuntz Jan 23 at 3:26 @Craig, I have a Person table and an Employee table (inherits Person), I created a Person, 6 years later this person became an employee, is there a way I can attach an Employee record to this existing Person so that he gets the additional features of Employee? – Shimmy Jan 23 at 3:31 @Shimmy, not with the EF. You could do it with raw SQL, because SQL doesn't "know" about class inheritance.
The best option, in my opinion, is to charge to a model where the Person to Employee relationship is one of aggregation rather than inheritance, for exactly the reason you describe. – Craig Stuntz Jan 23 at 15:25.
Regarding inheritance in EF take a look at this site, which explains the three different ways to use inheritance in EF. blogs.microsoft.co.il/blogs/gilf/archive....
You need to change your world view. Your view is that you have standard users with standard privileges and super users with additional privileges. The privileges aren't enumerated, they are implicit.
The new world view is that you maintain a list of all privileges, both standard and super and then in a mapping table you create a many to many map of which users have which privileges. When a user is granted super privileges, you just add mappings for the appropriate privileges to the mapping table. You don't need a PrivilegedUser class, just a list of privileges in the User class.
The privileges may be either standard or super.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.