How to use EnterpriseGeodatabaseWorkspace to edit the SDE

1700
4
Jump to solution
06-30-2017 03:12 AM
xipeng
by
New Contributor III

100.1 was released

Several objects have been added to this release

For example, EnterpriseGeodatabaseWorkspace FileGeodatabaseWorkspace, RasterWorkspace ShapefileWorkspace

But I don't know how to use them

How to use them to edit sde, FileGeodatabase, and Shape.

Can you give an example?

New working space

0 Kudos
1 Solution

Accepted Solutions
PreetiMaske
Esri Contributor

These workspaces allow dynamically requesting data from the below mentioned workspaces and render them as ArcGISMapImageLayer.Sublayer collection. Note, these workspaces require use of Local Server.

Below are some examples. You would need to replace the parts of code where it is requiring a path to data.

EnterpriseGeodataWorkspace: Displays dynamic layers based upon layers in an enterprise geodatabase(via database connection string) using local server.Uses the LocalServices.EnterpriseGeodatabaseWorkspace and Mapping.TableSublayerSource to display the layers in an enterprise geodatabase as ArcGISMapImageLayer.Sublayers. 

```

LocalMapService myLocalMapService = new LocalMapService(@"Path To MPK");

// Create an enterprise geodatabase workspace.
EnterpriseGeodatabaseWorkspace myEnterpriseGeodatabaseWorkspace = EnterpriseGeodatabaseWorkspace.CreateFromConnectionString("database connection string", "PASSWORD=pwd;SERVER=SQLSRV;INSTANCE=sdeinstance;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=connectionProp;DATABASE=DBName;USER=user;VERSION=DBversion;AUTHENTICATION_MODE=DBMS");

// Create an empty DynamicWorkspace and add a EnterpriseGeodatabaseWorkspace into it's collection.
List<DynamicWorkspace> myIEnumerableOfDynamicWorkpace = new List<DynamicWorkspace>();
myIEnumerableOfDynamicWorkpace.Add(myEnterpriseGeodatabaseWorkspace);

// Now set the DynamicWorkspace of the LocalMapService to the one just created.
myLocalMapService.SetDynamicWorkspaces(myIEnumerableOfDynamicWorkpace);

// Start the local map service.
await myLocalMapService.StartAsync();

// Create an ArcGIS map image layer using the same url as the local map service.
Esri.ArcGISRuntime.Mapping.ArcGISMapImageLayer myArcGISMapImageLayer = new Esri.ArcGISRuntime.Mapping.ArcGISMapImageLayer(myLocalMapService.Url);
myArcGISMapImageLayer.Name = "Enterprise";

// Get the first dynamic workspace from the local map service.
List<DynamicWorkspace> myListOfDynamicWorkspaces = (List<DynamicWorkspace>)myLocalMapService.GetDynamicWorkspaces();
DynamicWorkspace oneDynamicWorkspace = myListOfDynamicWorkspaces[0];

// Cast the DynamicWorkspace to a EnterpriseGeodatabaseWorkspace.
EnterpriseGeodatabaseWorkspace oneEnterpriseGeodatabaseWorkspace = (EnterpriseGeodatabaseWorkspace)oneDynamicWorkspace;

// Create a simple fill symbol
SimpleFillSymbol mySimpleFillSymbol = new SimpleFillSymbol();
mySimpleFillSymbol.Color = Colors.Aqua;
mySimpleFillSymbol.Style = SimpleFillSymbolStyle.Solid;

// Create a simple renderer
SimpleRenderer mySimpleRenderer3 = new SimpleRenderer();
mySimpleRenderer3.Symbol = mySimpleFillSymbol;

// Create a table sub-layer source using the id from the enterprise geodatabase workspace id and a specific layer in the enterprise geodatabase workspace
TableSublayerSource myTableSubLayerSource3 = new TableSublayerSource(oneEnterpriseGeodatabaseWorkspace.Id, "DB.DBO.Tablename");//Fullyqualified table name

// Create a new ArcGIS map image sub-layer based on the table sub-layer source
ArcGISMapImageSublayer myArcGISMapImageSublayer3 = new ArcGISMapImageSublayer(2, myTableSubLayerSource3);
myArcGISMapImageSublayer3.Renderer = mySimpleRenderer3;

// Add the ArcGIS map image sub-layer to the sub-layers collection of the ArcGIS map image layer
myArcGISMapImageLayer.Sublayers.Add(myArcGISMapImageSublayer3);

// Add the dynamic ArcGIS map image layer to the map.
MyMapView.Map.OperationalLayers.Add(myArcGISMapImageLayer);

```

FileGeoDatabaseWorkspace

Displays dynamic layers based upon layers in an enterprise geodatabase (via .sde file) using local server. Uses the
LocalServices.EnterpriseGeodatabaseWorkspace and Mapping.TableSublayerSource to display the layers in an enterprise geodatabase as ArcGISMapImageLayer.Sublayers.

```
LocalMapService myLocalMapService = new LocalMapService(@"Path to Mpk");

// Create an enterprise geodatabase workspace.
EnterpriseGeodatabaseWorkspace myEnterpriseGeodatabaseWorkspace = EnterpriseGeodatabaseWorkspace.CreateFromConnectionFile("sde file", "\\\\SdeFconnectionfile.sde");

// Create an empty DynamicWorkspace and add a EnterpriseGeodatabaseWorkspace into it's collection.
List<DynamicWorkspace> myIEnumerableOfDynamicWorkpace = new List<DynamicWorkspace>();
myIEnumerableOfDynamicWorkpace.Add(myEnterpriseGeodatabaseWorkspace);

// Now set the DynamicWorkspace of the LocalMapService to the one just created.
myLocalMapService.SetDynamicWorkspaces(myIEnumerableOfDynamicWorkpace);

// Start the local map service.
await myLocalMapService.StartAsync();

// Create an ArcGIS map image layer using the same url as the local map service.
Esri.ArcGISRuntime.Mapping.ArcGISMapImageLayer myArcGISMapImageLayer = new Esri.ArcGISRuntime.Mapping.ArcGISMapImageLayer(myLocalMapService.Url);
myArcGISMapImageLayer.Name = "Enterprise";

// Get the first dynamic workspace from the local map service.
List<DynamicWorkspace> myListOfDynamicWorkspaces = (List<DynamicWorkspace>)myLocalMapService.GetDynamicWorkspaces();
DynamicWorkspace oneDynamicWorkspace = myListOfDynamicWorkspaces[0];

// Cast the DynamicWorkspace to a EnterpriseGeodatabaseWorkspace.
EnterpriseGeodatabaseWorkspace oneEnterpriseGeodatabaseWorkspace = (EnterpriseGeodatabaseWorkspace)oneDynamicWorkspace;

// Create a simple fill symbol
SimpleFillSymbol mySimpleFillSymbol = new SimpleFillSymbol();
mySimpleFillSymbol.Color = Colors.Black;
mySimpleFillSymbol.Style = SimpleFillSymbolStyle.Solid;

// Create a simple renderer
SimpleRenderer mySimpleRenderer3 = new SimpleRenderer();
mySimpleRenderer3.Symbol = mySimpleFillSymbol;

// Create a table sub-layer source using the id from the enterprise geodatabase workspace id and a specific layer in the enterprise geodatabase workspace
TableSublayerSource myTableSubLayerSource3 = new TableSublayerSource(oneEnterpriseGeodatabaseWorkspace.Id, "Tablename");

// Create a new ArcGIS map image sub-layer based on the table sub-layer source
ArcGISMapImageSublayer myArcGISMapImageSublayer3 = new ArcGISMapImageSublayer(2, myTableSubLayerSource3);
myArcGISMapImageSublayer3.Renderer = mySimpleRenderer3;

// Add the ArcGIS map image sub-layer to the sub-layers collection of the ArcGIS map image layer
myArcGISMapImageLayer.Sublayers.Add(myArcGISMapImageSublayer3);

// Add the dynamic ArcGIS map image layer to the map.
MyMapView.Map.OperationalLayers.Add(myArcGISMapImageLayer);

```

RasterWorkspace:

Displays dynamic raster layers based in a folder on disk using local server. Uses the LocalServices.RasterWorkspace and Mapping.RasterSublayerSource to display the raster layers in a folder on disk as ArcGISMapImageLayer.Sublayers.

```
LocalMapService myLocalMapService = new LocalMapService(@" Path to mpk");

// Create a raster geodatabase workspace (aka. a folder on disk that contains raster images).
RasterWorkspace myRasterWorkspace = new RasterWorkspace("raster_wkspc", @"PathtoRasterFolder");

// Create an empty DynamicWorkspace and add a RasterWorkspace into it's collection.
List<Esri.ArcGISRuntime.LocalServices.DynamicWorkspace> myIEnumerableOfDynamicWorkpace = new List<Esri.ArcGISRuntime.LocalServices.DynamicWorkspace>();
myIEnumerableOfDynamicWorkpace.Add(myRasterWorkspace);

// Now set the DynamicWorkspace of the LocalMapService to the one just created.
myLocalMapService.SetDynamicWorkspaces(myIEnumerableOfDynamicWorkpace);

// Start the local map service.
await myLocalMapService.StartAsync();

// Create an ArcGIS map image layer using the same url as the local map service.
ArcGISMapImageLayer myArcGISMapImageLayer = new ArcGISMapImageLayer(myLocalMapService.Url);
myArcGISMapImageLayer.Name = "WithRaster";

// Get the first dynamic workspace from the local map service.
List<DynamicWorkspace> myListOfDynamicWorkspaces = (List<DynamicWorkspace>)myLocalMapService.GetDynamicWorkspaces();
DynamicWorkspace oneDynamicWorkspace = myListOfDynamicWorkspaces[0];

// Cast the DynamicWorkspace to a RasterWorkspace
RasterWorkspace oneRasterWorkspace = (RasterWorkspace)oneDynamicWorkspace;

// Create a raster sub-layer source using the id from the raster workspace id and a specific raster image by file name.
RasterSublayerSource myRasterSubLayerSource1 = new RasterSublayerSource(oneRasterWorkspace.Id, "Raster.tif");

// Create a new ArcGIS map image sub-layer based on the raster sub-layer source .
ArcGISMapImageSublayer myArcGISMapImageSublayer1 = new ArcGISMapImageSublayer(0, myRasterSubLayerSource1);

// Add the ArcGIS map image sub-layer to the sub-layers collection of the ArcGIS map image layer.
// NOTE: default rendering of the raster image will be used.
myArcGISMapImageLayer.Sublayers.Add(myArcGISMapImageSublayer1);

// Add the dynamic ArcGIS map image layer to the map.
MyMapView.Map.OperationalLayers.Add(myArcGISMapImageLayer);

```

ShapeFileWorkspace:

Displays dynamic layers based upon shapefiles using local server. Uses the LocalServices.ShapefileWorkspace and
Mapping.TableSublayerSource to display the shapefiles as ArcGISMapImageLayer.Sublayers.

```

LocalMapService myLocalMapService = new LocalMapService(@"Path to mpk");

// Create a shapefile workspace.
ShapefileWorkspace myShapefileWorkspace = new ShapefileWorkspace("MyShapefileWorkspace", @"PathToShapefile");

// Create an empty DynamicWorkspace and add a ShapefileWorkspace into it's collection.
List<DynamicWorkspace> myIEnumerableOfDynamicWorkpace = new List<DynamicWorkspace>();
myIEnumerableOfDynamicWorkpace.Add(myShapefileWorkspace);

// Now set the DynamicWorkspace of the LocalMapService to the one just created.
myLocalMapService.SetDynamicWorkspaces(myIEnumerableOfDynamicWorkpace);

// Start the local map service.
await myLocalMapService.StartAsync();

// Create an ArcGIS map image layer using the same url as the local map service.
ArcGISMapImageLayer myArcGISMapImageLayer = new ArcGISMapImageLayer(myLocalMapService.Url);

// Get the first dynamic workspace from the local map service.
List<DynamicWorkspace> myListOfDynamicWorkspaces = (List<DynamicWorkspace>)myLocalMapService.GetDynamicWorkspaces();
DynamicWorkspace oneDynamicWorkspace = myListOfDynamicWorkspaces[0];

// Cast the DynamicWorkspace to a ShapefileWorkspace
ShapefileWorkspace oneShapeFileWorkspace = (ShapefileWorkspace)oneDynamicWorkspace;

// --------------------------------------------------------------------------

// Create a simple marker symbol
SimpleMarkerSymbol mySimpleMarkerSymbol = new SimpleMarkerSymbol();
mySimpleMarkerSymbol.Color = Colors.Black;
mySimpleMarkerSymbol.Size = 10;
mySimpleMarkerSymbol.Style = SimpleMarkerSymbolStyle.Circle;

// Create a simple renderer
SimpleRenderer mySimpleRenderer1 = new SimpleRenderer();
mySimpleRenderer1.Symbol = mySimpleMarkerSymbol;

// Create a table sub-layer source using the id from the shapefile workspace id and a specific shapefile in the workspace
TableSublayerSource myTableSubLayerSource1 = new TableSublayerSource(oneShapeFileWorkspace.Id, "ShapeFileName.shp");

// Create a new ArcGIS map image sub-layer based on the table sub-layer source
ArcGISMapImageSublayer myArcGISMapImageSublayer1 = new ArcGISMapImageSublayer(0, myTableSubLayerSource1);
myArcGISMapImageSublayer1.Renderer = mySimpleRenderer1;

// Add the ArcGIS map image sub-layer to the sub-layers collection of the ArcGIS map image layer
myArcGISMapImageLayer.Sublayers.Add(myArcGISMapImageSublayer1);

// Add the dynamic ArcGIS map image layer to the map.
MyMapView.Map.OperationalLayers.Add(myArcGISMapImageLayer);

```

View solution in original post

0 Kudos
4 Replies
PreetiMaske
Esri Contributor

These workspaces allow dynamically requesting data from the below mentioned workspaces and render them as ArcGISMapImageLayer.Sublayer collection. Note, these workspaces require use of Local Server.

Below are some examples. You would need to replace the parts of code where it is requiring a path to data.

EnterpriseGeodataWorkspace: Displays dynamic layers based upon layers in an enterprise geodatabase(via database connection string) using local server.Uses the LocalServices.EnterpriseGeodatabaseWorkspace and Mapping.TableSublayerSource to display the layers in an enterprise geodatabase as ArcGISMapImageLayer.Sublayers. 

```

LocalMapService myLocalMapService = new LocalMapService(@"Path To MPK");

// Create an enterprise geodatabase workspace.
EnterpriseGeodatabaseWorkspace myEnterpriseGeodatabaseWorkspace = EnterpriseGeodatabaseWorkspace.CreateFromConnectionString("database connection string", "PASSWORD=pwd;SERVER=SQLSRV;INSTANCE=sdeinstance;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=connectionProp;DATABASE=DBName;USER=user;VERSION=DBversion;AUTHENTICATION_MODE=DBMS");

// Create an empty DynamicWorkspace and add a EnterpriseGeodatabaseWorkspace into it's collection.
List<DynamicWorkspace> myIEnumerableOfDynamicWorkpace = new List<DynamicWorkspace>();
myIEnumerableOfDynamicWorkpace.Add(myEnterpriseGeodatabaseWorkspace);

// Now set the DynamicWorkspace of the LocalMapService to the one just created.
myLocalMapService.SetDynamicWorkspaces(myIEnumerableOfDynamicWorkpace);

// Start the local map service.
await myLocalMapService.StartAsync();

// Create an ArcGIS map image layer using the same url as the local map service.
Esri.ArcGISRuntime.Mapping.ArcGISMapImageLayer myArcGISMapImageLayer = new Esri.ArcGISRuntime.Mapping.ArcGISMapImageLayer(myLocalMapService.Url);
myArcGISMapImageLayer.Name = "Enterprise";

// Get the first dynamic workspace from the local map service.
List<DynamicWorkspace> myListOfDynamicWorkspaces = (List<DynamicWorkspace>)myLocalMapService.GetDynamicWorkspaces();
DynamicWorkspace oneDynamicWorkspace = myListOfDynamicWorkspaces[0];

// Cast the DynamicWorkspace to a EnterpriseGeodatabaseWorkspace.
EnterpriseGeodatabaseWorkspace oneEnterpriseGeodatabaseWorkspace = (EnterpriseGeodatabaseWorkspace)oneDynamicWorkspace;

// Create a simple fill symbol
SimpleFillSymbol mySimpleFillSymbol = new SimpleFillSymbol();
mySimpleFillSymbol.Color = Colors.Aqua;
mySimpleFillSymbol.Style = SimpleFillSymbolStyle.Solid;

// Create a simple renderer
SimpleRenderer mySimpleRenderer3 = new SimpleRenderer();
mySimpleRenderer3.Symbol = mySimpleFillSymbol;

// Create a table sub-layer source using the id from the enterprise geodatabase workspace id and a specific layer in the enterprise geodatabase workspace
TableSublayerSource myTableSubLayerSource3 = new TableSublayerSource(oneEnterpriseGeodatabaseWorkspace.Id, "DB.DBO.Tablename");//Fullyqualified table name

// Create a new ArcGIS map image sub-layer based on the table sub-layer source
ArcGISMapImageSublayer myArcGISMapImageSublayer3 = new ArcGISMapImageSublayer(2, myTableSubLayerSource3);
myArcGISMapImageSublayer3.Renderer = mySimpleRenderer3;

// Add the ArcGIS map image sub-layer to the sub-layers collection of the ArcGIS map image layer
myArcGISMapImageLayer.Sublayers.Add(myArcGISMapImageSublayer3);

// Add the dynamic ArcGIS map image layer to the map.
MyMapView.Map.OperationalLayers.Add(myArcGISMapImageLayer);

```

FileGeoDatabaseWorkspace

Displays dynamic layers based upon layers in an enterprise geodatabase (via .sde file) using local server. Uses the
LocalServices.EnterpriseGeodatabaseWorkspace and Mapping.TableSublayerSource to display the layers in an enterprise geodatabase as ArcGISMapImageLayer.Sublayers.

```
LocalMapService myLocalMapService = new LocalMapService(@"Path to Mpk");

// Create an enterprise geodatabase workspace.
EnterpriseGeodatabaseWorkspace myEnterpriseGeodatabaseWorkspace = EnterpriseGeodatabaseWorkspace.CreateFromConnectionFile("sde file", "\\\\SdeFconnectionfile.sde");

// Create an empty DynamicWorkspace and add a EnterpriseGeodatabaseWorkspace into it's collection.
List<DynamicWorkspace> myIEnumerableOfDynamicWorkpace = new List<DynamicWorkspace>();
myIEnumerableOfDynamicWorkpace.Add(myEnterpriseGeodatabaseWorkspace);

// Now set the DynamicWorkspace of the LocalMapService to the one just created.
myLocalMapService.SetDynamicWorkspaces(myIEnumerableOfDynamicWorkpace);

// Start the local map service.
await myLocalMapService.StartAsync();

// Create an ArcGIS map image layer using the same url as the local map service.
Esri.ArcGISRuntime.Mapping.ArcGISMapImageLayer myArcGISMapImageLayer = new Esri.ArcGISRuntime.Mapping.ArcGISMapImageLayer(myLocalMapService.Url);
myArcGISMapImageLayer.Name = "Enterprise";

// Get the first dynamic workspace from the local map service.
List<DynamicWorkspace> myListOfDynamicWorkspaces = (List<DynamicWorkspace>)myLocalMapService.GetDynamicWorkspaces();
DynamicWorkspace oneDynamicWorkspace = myListOfDynamicWorkspaces[0];

// Cast the DynamicWorkspace to a EnterpriseGeodatabaseWorkspace.
EnterpriseGeodatabaseWorkspace oneEnterpriseGeodatabaseWorkspace = (EnterpriseGeodatabaseWorkspace)oneDynamicWorkspace;

// Create a simple fill symbol
SimpleFillSymbol mySimpleFillSymbol = new SimpleFillSymbol();
mySimpleFillSymbol.Color = Colors.Black;
mySimpleFillSymbol.Style = SimpleFillSymbolStyle.Solid;

// Create a simple renderer
SimpleRenderer mySimpleRenderer3 = new SimpleRenderer();
mySimpleRenderer3.Symbol = mySimpleFillSymbol;

// Create a table sub-layer source using the id from the enterprise geodatabase workspace id and a specific layer in the enterprise geodatabase workspace
TableSublayerSource myTableSubLayerSource3 = new TableSublayerSource(oneEnterpriseGeodatabaseWorkspace.Id, "Tablename");

// Create a new ArcGIS map image sub-layer based on the table sub-layer source
ArcGISMapImageSublayer myArcGISMapImageSublayer3 = new ArcGISMapImageSublayer(2, myTableSubLayerSource3);
myArcGISMapImageSublayer3.Renderer = mySimpleRenderer3;

// Add the ArcGIS map image sub-layer to the sub-layers collection of the ArcGIS map image layer
myArcGISMapImageLayer.Sublayers.Add(myArcGISMapImageSublayer3);

// Add the dynamic ArcGIS map image layer to the map.
MyMapView.Map.OperationalLayers.Add(myArcGISMapImageLayer);

```

RasterWorkspace:

Displays dynamic raster layers based in a folder on disk using local server. Uses the LocalServices.RasterWorkspace and Mapping.RasterSublayerSource to display the raster layers in a folder on disk as ArcGISMapImageLayer.Sublayers.

```
LocalMapService myLocalMapService = new LocalMapService(@" Path to mpk");

// Create a raster geodatabase workspace (aka. a folder on disk that contains raster images).
RasterWorkspace myRasterWorkspace = new RasterWorkspace("raster_wkspc", @"PathtoRasterFolder");

// Create an empty DynamicWorkspace and add a RasterWorkspace into it's collection.
List<Esri.ArcGISRuntime.LocalServices.DynamicWorkspace> myIEnumerableOfDynamicWorkpace = new List<Esri.ArcGISRuntime.LocalServices.DynamicWorkspace>();
myIEnumerableOfDynamicWorkpace.Add(myRasterWorkspace);

// Now set the DynamicWorkspace of the LocalMapService to the one just created.
myLocalMapService.SetDynamicWorkspaces(myIEnumerableOfDynamicWorkpace);

// Start the local map service.
await myLocalMapService.StartAsync();

// Create an ArcGIS map image layer using the same url as the local map service.
ArcGISMapImageLayer myArcGISMapImageLayer = new ArcGISMapImageLayer(myLocalMapService.Url);
myArcGISMapImageLayer.Name = "WithRaster";

// Get the first dynamic workspace from the local map service.
List<DynamicWorkspace> myListOfDynamicWorkspaces = (List<DynamicWorkspace>)myLocalMapService.GetDynamicWorkspaces();
DynamicWorkspace oneDynamicWorkspace = myListOfDynamicWorkspaces[0];

// Cast the DynamicWorkspace to a RasterWorkspace
RasterWorkspace oneRasterWorkspace = (RasterWorkspace)oneDynamicWorkspace;

// Create a raster sub-layer source using the id from the raster workspace id and a specific raster image by file name.
RasterSublayerSource myRasterSubLayerSource1 = new RasterSublayerSource(oneRasterWorkspace.Id, "Raster.tif");

// Create a new ArcGIS map image sub-layer based on the raster sub-layer source .
ArcGISMapImageSublayer myArcGISMapImageSublayer1 = new ArcGISMapImageSublayer(0, myRasterSubLayerSource1);

// Add the ArcGIS map image sub-layer to the sub-layers collection of the ArcGIS map image layer.
// NOTE: default rendering of the raster image will be used.
myArcGISMapImageLayer.Sublayers.Add(myArcGISMapImageSublayer1);

// Add the dynamic ArcGIS map image layer to the map.
MyMapView.Map.OperationalLayers.Add(myArcGISMapImageLayer);

```

ShapeFileWorkspace:

Displays dynamic layers based upon shapefiles using local server. Uses the LocalServices.ShapefileWorkspace and
Mapping.TableSublayerSource to display the shapefiles as ArcGISMapImageLayer.Sublayers.

```

LocalMapService myLocalMapService = new LocalMapService(@"Path to mpk");

// Create a shapefile workspace.
ShapefileWorkspace myShapefileWorkspace = new ShapefileWorkspace("MyShapefileWorkspace", @"PathToShapefile");

// Create an empty DynamicWorkspace and add a ShapefileWorkspace into it's collection.
List<DynamicWorkspace> myIEnumerableOfDynamicWorkpace = new List<DynamicWorkspace>();
myIEnumerableOfDynamicWorkpace.Add(myShapefileWorkspace);

// Now set the DynamicWorkspace of the LocalMapService to the one just created.
myLocalMapService.SetDynamicWorkspaces(myIEnumerableOfDynamicWorkpace);

// Start the local map service.
await myLocalMapService.StartAsync();

// Create an ArcGIS map image layer using the same url as the local map service.
ArcGISMapImageLayer myArcGISMapImageLayer = new ArcGISMapImageLayer(myLocalMapService.Url);

// Get the first dynamic workspace from the local map service.
List<DynamicWorkspace> myListOfDynamicWorkspaces = (List<DynamicWorkspace>)myLocalMapService.GetDynamicWorkspaces();
DynamicWorkspace oneDynamicWorkspace = myListOfDynamicWorkspaces[0];

// Cast the DynamicWorkspace to a ShapefileWorkspace
ShapefileWorkspace oneShapeFileWorkspace = (ShapefileWorkspace)oneDynamicWorkspace;

// --------------------------------------------------------------------------

// Create a simple marker symbol
SimpleMarkerSymbol mySimpleMarkerSymbol = new SimpleMarkerSymbol();
mySimpleMarkerSymbol.Color = Colors.Black;
mySimpleMarkerSymbol.Size = 10;
mySimpleMarkerSymbol.Style = SimpleMarkerSymbolStyle.Circle;

// Create a simple renderer
SimpleRenderer mySimpleRenderer1 = new SimpleRenderer();
mySimpleRenderer1.Symbol = mySimpleMarkerSymbol;

// Create a table sub-layer source using the id from the shapefile workspace id and a specific shapefile in the workspace
TableSublayerSource myTableSubLayerSource1 = new TableSublayerSource(oneShapeFileWorkspace.Id, "ShapeFileName.shp");

// Create a new ArcGIS map image sub-layer based on the table sub-layer source
ArcGISMapImageSublayer myArcGISMapImageSublayer1 = new ArcGISMapImageSublayer(0, myTableSubLayerSource1);
myArcGISMapImageSublayer1.Renderer = mySimpleRenderer1;

// Add the ArcGIS map image sub-layer to the sub-layers collection of the ArcGIS map image layer
myArcGISMapImageLayer.Sublayers.Add(myArcGISMapImageSublayer1);

// Add the dynamic ArcGIS map image layer to the map.
MyMapView.Map.OperationalLayers.Add(myArcGISMapImageLayer);

```

0 Kudos
xipeng
by
New Contributor III

Thank you very much for such a detailed answer, but I can't edit Feature which data source is from sde, GDB, shape,through ArcGISMapImageLayer,  and then unable to synchronize the data. Is that true?

I want to edit the data

Can you do that?

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

To clarify the layer types:

`ArcGISMapImageLayer` - Created for MapServer endpoints. Images are rendered server side (including "server-side" in ArcGIS Runtime Local Server). Does not expose edit capabilities.

`FeatureLayer` (`ServiceFeatureTable`) - Created for FeatureServer endpoints (FeatureServer + layer index). Features (attributes, geometry, attachments, and relationships) are returned from the server to the client app in response to queries. Features can be added, updated, and deleted via the feature service.

To edit data in an Enterprise Geodatabase you can:

- Use ArcMap 10.5.1 to create a Map Package (.mpk) that references your geodatabase data.

- Start a `LocalFeatureService` using the API.

- Use the Uri of the local feature service to create a `ServiceFeatureTable`.

- Optionally create a `FeatureLayer` from the service feature table if you want to view/edit in the `MapView`.

- Add, update, or delete features in the service feature table.

For more information see ServiceFeatureTable Class 

Cheers

Mike

0 Kudos
xipeng
by
New Contributor III

Thank you very much for your reply. I hope Runtime can support the editor later

0 Kudos