The MapDotNet UX edit model is used for feature editing. The edit model uses classes in ISC.MapDotNetServer.Common and ISC.MapDotNetServer.Common.Data. Note that the contents of these namespaces are slightly different under Silverlight. These differences will be discussed where applicable.
The edit model is used to edit data in map layers. (Requests can also be constructed to edit data tables that are not represented by map layers but this is a less common scenario.) The EditRequest class is used to encapsulate row edits. An EditRequest is serialized and passed to an instance of the feature update service, FeatureUpdateService.svc. In the RIM controls, the Services class can be used to create a client proxy for the feature update service. Otherwise, you can create one from a service reference.
The EditRequest class has the following properties:
WhereClauseOverride - this is not used for edit requests.
In the 6.x series, the edit model used an ADO.Net DataTable to pass data to be edited, with RowState indicating the action to perform. To support editing under Silverlight in UX, it was necessary to revise this model. The ISC.MapDotNetServer.Common.Data.EditDataModel namespace contains DataTable, DataColumn, DataRow, and DataRowState members that are very similar to their ADO.Net counterparts. They support a subset of the methods of their counterparts, implementing the methods and properties most commonly used in client code in our earlier edit model. However, our DataTable implementation differs from an ADO.Net DataTable in the following significant ways.
The DataTable is used both to pass data to the server and to return results to the client. Create the Data for an EditRequest in the following way.
The following code sample demonstrates the creation of an EditRequest with a single row of data to insert.
EditRequest ereq = new EditRequest();
ereq.DataSourceSpecification = new MapLayerDataSourceSpecification("mapID", "layerID");
ereq.Data = new DataTable();
ereq.Data.TableName = "layerID";
ereq.Data.PrimaryKey = ereq.Data.Columns.Add("id", typeof(int));
DataRow trow = ereq.Data.NewRow();
trow["shape"] = new ISC.MapDotNetServer.Common.Point(-90.0, 36.0).Serialize();
trow["label"] = "point 1";
Unlike the map or query models, the edit model does not have an EditResponse class corresponding to its EditRequest class. What is returned from the service call is a serialized DataTable. The TableError property will be set if an error prevented the edits from being executed. Otherwise, there will be a DataRow in the response for every row in the request. However, the only column present will be the primary key column, if there was one. RowState will be unchanged and RowError may be set.
You can check HasRowErrors on the DataTable to see if there are rows with errors and call GetErrorRows to get all rows with errors.
If the edit table had a primary key column defined and there were insert rows, the returned table will hold the new primary key values for newly inserted rows.
string Edit(string editRequest);
This is the only method of the feature update service. It takes a serialized EditRequest and returns a serialized EditDataModel.DataTable. The Edit may not be canceled once it is started.