This question is locked. New answers and comments are not allowed.
public class Person |
{ |
public Int32 ID { get; set; } |
public Int32 FavoriteColorID { get; set; } |
public Color FavoriteColor { get; set; } |
} |
public class Color |
{ |
public Int32 ID { get; set; } |
public String ColorName { get; set; } |
} |
Say I have a Person object and a Color object.
Usually, I just add a foreign key constraint from the FavoriteColorID property to the ID of the Color table. Since, I am experimenting with Open Access Forward Mapping, how do I create this relationship with these two classes so that I can access the person's favorite color in the following syntax?
myPersonObject.FavoriteColor.ColorName |
I am also assuming that this related object would be eagerly loaded when we retrieved myPersonObject from the database. I am not clear if my strategy is correct but I am used to it with Entities Framework.
I can see two scenarios for using the FavoriteColor field; the first is when I am updating or creating the person's favorite color; the second is when I am displaying the person's favorite color in statically. In the latter case it seems to me, that you should always have that color available in the Person object (ie loaded eagerly) and stored in the FavoriteColor property. I could use a method GetFavoriteColorbyID everytime I needed that particular Color object or any of its properties but this seems like an extra database trip.
Is there an implementation where I can access the eagerly loaded FavoriteColor/(Color object)? This is straight forward in the Entities Framework. Does this work with OpenAccess using Forward Mapping?
Jaime