ASP.NET MVC - NHibernate - DropDownLists -
I am just starting with ASP.NET MVC and I am using NHibernate for my data reference. I have placed foreign key areas in my unit sections so that it can be expected to work with the list drop down, but this is not the case.
Here is my post-back action:
var user = userRepository.GetById (id); If (TryUpdateModel (user, "user", new [] {"user name", "rolled"})) look back (user); // update the role user.Role = roleRepository.GetById (user.RoleID);
This lets me user. My validation argument is allowed on the relied property.
Until it saves it, everything works fine till then. Here is my user and mapping class:
Public Virtual User User ID {get; Set; } [Required (Error Message = "Username Required")] Public Virtual String Username {get; Set; } [Required (Error Message = "Required Role")] Public Virtual Ent RollID {Received; Set; } Role of public virtual role {received; Set; } Public usermap () {table ("user"); ID (x = & gt; x.UserID); Map (x = & gt; x.UserName); Map (x = & gt; x.RoleID); References (x = & gt; x roll, "rolled"); }
Although it throws an error when it tries to make the change I tried to remove the map (x => x.RoleID); The above mapping and the insert went successfully but then the data was not populated when displaying the user.
My favorite solution is to remove the RoleID property from the user unit (as suggested by NHibernate) but I have to handle my verification logic.
I would appreciate it if someone can help thank you
The best way to find out is this:
[HTTP Post, Valid Antifreeze Token] Create Public Action Result (Form Collection Collection) {var user = new user (); If (TryUpdateModel (user, new [] {"user name", "role"})) see return (user); ...} [HTTP Post, Valid Antifurrence Took] Public Action Result Edit (Ent ID, Form Collection Collection, String Return URL) {var User = User Repository.GetBiID; User.Role = new role (); // If necessary to prevent any other problem on saving! (TryUpdateModel (user, new [] {"user name", "role"})) View return (user); ...}
I am relatively happy with my HMI solution but if someone knows how I can get rid of the user. Reel = new role (); I appreciate the editing of the action if they can share thanks
btw If you are seeing more than one data back, when your verification fails and you need to get it ( Retrieve roles for example). Again you will have to rollback back the changes made in the nineteennet transaction to prevent any other problem. Hope this saves some time somebody :)
Comments
Post a Comment