AnsweredAssumed Answered

.net SDK - Adding/Creating a feature... default values?

Question asked by flyinb on Nov 9, 2016
Latest reply on Nov 9, 2016 by flyinb

I am trying to figure out how to use a field's default value when using the .net c# SDK when adding a feature. 

 

In ArcGIS, in the Feature Class properties, each field can have a default value:

 

However, I can't seem to find the Default Value via the SDK.  Here is my code:

var table = new ServiceFeatureTable
{
ServiceUri = url,
OutFields = new OutFields(OutFields.All)
};
await GenerateToken(url).ConfigureAwait(false);
await table.InitializeAsync(table.SpatialReference).ConfigureAwait(false);
var schemaFields = table.Schema.Fields.ToList();
var feature = new GeodatabaseFeature(table.Schema)
{
Geometry = geometry
};

foreach (var attribute in attributes)
{
var field = schemaFields.FirstOrDefault(x => x.Name.ToLower().Equals(attribute.Key.ToLower()));
if (field != null)
{
feature.Attributes[attribute.Key] = attribute.Value != null ? TranslateField(field, attribute.Value) : null;
}
}

await table.AddAsync(feature);

var result = await table.ApplyEditsAsync(true);

 

nowhere in the schema field or the feature class is there an option to apply a default value.

Outcomes