I have two listboxes where I copy data from one listbox to another listbox.
The rows that get moved into the second listbox need to be saved to a different table than the table that the records originated.
So, I have a UserProfile table with a list of people in the entire company. I select only the individuals that will participate in the project.
I need to save these individuals into a different table that only has people who are members of that project. I used HttpRequest to get the new individuals from the second list box. I then have a method using Linq Query that retrieves the rows by UserId from the UserProfile table.
Now that I have the rows I need from the UserProfile table, how do I go about inserting these individuals into a new table? I already have an IQueryable of the people I need to save to this table. How do I save these list of members into this new table in asp.net mvc and entity framework? Thanks
Is the IQueryable class of the same type of your table that you are inserting into? I’m assuming yes but if not you’d just need to map columns first.
Here is my controller code for inserting a category record, my table is named lm_r_category in Entity Framework. This code gets triggered from a Telerik ASP.MVC grid via Http Post but could be triggered however you’d like.
lm_r_category is my EF class for the table I’m inserting to. If you are using a different class, simply create a new instance of lm_r_category and map column values before doing the AddObject. As you can see doing Inserts in EF is extremely simple.