These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Foreign Key AND Ref Entity?
PostPosted: Fri Dec 18, 2009 10:39 pm 
Newbie

Joined: Fri Dec 18, 2009 10:30 pm
Posts: 1
I have a need to map both a related entity and it's id. For example:

public class Person : Entity
{

public virtual string FullName { get; set; }
public virtual int FavoriteFoodId { get; set; }
public FavoriteFood FavoriteFood { get; protected set; }

}

The reason is that I am using an Html.DropDownList and the data value for each option is the favorite food id. On post, the receiving action binds a new Person. The person class must have a property setup to receive that data, or I have nothing which to determine what food they selected. I can't name the drop down 'FavoriteFood.Id' either because the binder looks for a field with that exact name, and doesn't know to try using object.field. I can't apply a prefix to a single field either, they affect the whole entity on bind. So I am kind of left scratching my head on this one.

In testing, it seems you can have one or the other (field or entity) but not both. Adding both generates index errors upon query. I really don't want to resort to yet another third party component set just get this to work. Nor do I need some convoluted workaround.

If there's a way to do this, please let me know. Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.