Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
EF referencing the same table twice
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01552354
Message ID:
01552390
Vues:
62
This message has been marked as a message which has helped to the initial question of the thread.
You can either use the [ForeignKey] attribute for the actual ID values or you can just set a reference to the the object in question:
public Operator ModifiedBy {get; set; }
public Operator EnteredBy {get; set;} 
This effectively creates the relationship (at least with CodeFirst).

Personally I prefer to have both the foreign key and the object reference because in some scenarios you can avoid having to load the related objects just to update the parent. You can do both if needed.

+++ Rick ---


>Hi everybody,
>
>I am trying to create classses for the existing database by coding them manually. I have EnteredBy and ModifiedBy columns in the table that both refer to the same column from Operators table. I will require an authorization and I will set these columns to the currently logged operator.
>
>My question is - when I define my class, how should I make these relations?
>
>Thanks in advance.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform