I have fun with EF and peeled off.
I originally used the following bit of code using standard linq, which essentially injects some data into a table.
ManagePreferencesDataContext manpref = new ManagePreferencesDataContext();
tblManagePreference prefMemberID = new tblManagePreference();
{
prefMemberID.Username = CreateUserWizard1.UserName;
prefMemberID.MemberID = tbxMemberID.Text.ToString();
prefMemberID.LocationID = tbxLocationID.Text.ToString();
prefMemberID.Preference = "MemberID";
}
tblManagePreference prefLocationID = new tblManagePreference();
{
prefLocationID.Username = CreateUserWizard1.UserName;
prefLocationID.MemberID = tbxMemberID.Text.ToString();
prefLocationID.LocationID = tbxLocationID.Text.ToString();
prefLocationID.Preference = "LocationID";
}
List<tblManagePreference> ie = new List<tblManagePreference>();
ie.Add(prefMemberID);
ie.Add(prefLocationID);
manpref.tblManagePreferences.InsertAllOnSubmit(ie);
manpref.SubmitChanges();
Now, Ive tried to play the same or similar code using EF and completely peeled off.
I tried using the list and .AddTotblManagePreferences, but I get the "Deprecated method for adding a new object to the tblManagePreferences EntitySet". Instead, use the .Add method of the associated ObjectSet property instead.
I took a quick look at ObjectSet, but Im really not sure how to change the code.
VDSORDAL.PDC_VDSOREntities manpref = new PDC_VDSOREntities();
tblUserPreference prefMemberID = new tblUserPreference();
{
prefMemberID.Username = CreateUserWizard1.UserName;
prefMemberID.MemberID = tbxMemberID.Text.ToString();
prefMemberID.LocationID = tbxLocationID.Text.ToString();
prefMemberID.ColumnName = "MemberID";
}
tblUserPreference prefLocationID = new tblUserPreference();
{
prefLocationID.Username = CreateUserWizard1.UserName;
prefLocationID.MemberID = tbxMemberID.Text.ToString();
prefLocationID.LocationID = tbxLocationID.Text.ToString();
prefLocationID.ColumnName = "LocationID";
}
List<tblUserPreference> ie = new List<tblUserPreference>();
ie.Add(prefMemberID);
ie.Add(prefLocationID);
manpref.AddObject(PDC_VDSOREntities,ie);
manpref.SaveChanges();
If someone has used something in these lines before or could point me in the right direction, Id would be very grateful.
, , .