Please can somebody help me on the above question? I am using SimpleData in my project and trying to update records as follows but get the error mentioned above.
var releasedHosts = show_crm.tblName.Update(ID: Id, ID: newId);
Error Message:
Named argument 'ID' cannot be specified multiple times
Thank you.
string siteName = ddlDeleteSite.SelectedItem.Text;
if (!siteName.Equals("Unknown-Site") && siteName != null)
{
int siteId = Convert.ToInt32(ddlDeleteSite.SelectedValue);
//Update record to Attach Hostname to selected site by updating it's SiteID and remove it from 'Unknown-Site'
var updatedSite = show_crm.tblSites.UpdateBySiteID(SiteID: siteId, Deleted: true);
if (updatedSite != null)
{
var unknownSite = show_crm.tblSites.FindBySiteName("Unknown-Site");
int unknownSiteId = unknownSite.SiteID;
var releasedHosts = show_crm.tblHostNames.Update(new { SiteID = unknownSiteId }, new { SiteID = siteId });//(show_crm.tblHostNames.SiteID == siteId, SiteID: unknownSiteId);
}
lblDeleteSiteStatus.Text = ddlDeleteSite.SelectedItem.Text + " deleted successfully.";
lblDeleteSiteStatus.Visible = true;
RetrieveSites(ddlDeleteSite);
}
When you want to use a column as criteria and update it, you have to use either the criteria overload of update:
show_crm.tblName.UpdateAll(show_crm.tblName.ID == Id, ID: newId);
or you can specify two objects as the criteria to do an optimistic-concurrency type of this:
show_crm.tblName.Update(new {ID = newId}, new {ID = Id});
In the latter form, the first object contains the new values and the second one the "original" values.