var fields = l.LayerInfo.Fields.Where(f => f.Domain is CodedValueDomain && (f.Domain as CodedValueDomain).CodedValues.Count > 0); foreach (var f in fields) { if (g.Attributes[f.Name] == null) { var d = f.Domain as CodedValueDomain; g.Attributes[f.Name] = d.CodedValues.FirstOrDefault().Key; } }