public static YamlNode GetNodes(Asset source) { var root = new YamlMappingNode(); var assetType = source.AssetType; root.Add("asset", assetType); JObject obj = JObject.FromObject(source.GetChangesDto()); obj.Remove("AssetType"); YamlMappingNode attributes = new YamlMappingNode(); var tuples = (from prop in ( from token in JToken.FromObject(obj) where token.Type == JTokenType.Property select token as JProperty ) select GetUpdateAttribute(prop) ); foreach (var tuple in tuples) { attributes.Add(tuple.Item1, tuple.Item2); } root.Add("attributes", attributes); return root; }