/// <summary> /// Serializes the specified records into json that can be used with <see cref="SqlServerMergeQueryBuilder"/>'s sql /// </summary> public override string SerializeForMerge(IEnumerable <T> records) { var toSerialize = new JArray(); foreach (var(record, index) in records.Indexed()) { var jsonRecord = new JObject(new JProperty("_", index)); foreach (var(property, alias) in Aliases.AsTuples()) { jsonRecord.Add(new JProperty($"_{alias}", GetPropertyValue(record, property))); } toSerialize.Add(jsonRecord); } return(toSerialize.ToString(Newtonsoft.Json.Formatting.None)); }
/// <summary> /// Serializes the specified records into xml that can be used with <see cref="SqlServerMergeQueryBuilder"/>'s sql /// </summary> public override string SerializeForMerge(IEnumerable <T> records) { var toSerialize = new XElement("_"); foreach (var(record, index) in records.Indexed()) { var xmlRecord = new XElement("_", new XAttribute("_", index)); foreach (var(property, alias) in Aliases.AsTuples()) { //--Don't serialize null values if (GetPropertyValue(record, property) is { } value) { xmlRecord.Add(new XAttribute($"_{alias}", value)); } } toSerialize.Add(xmlRecord); } return(toSerialize.ToString(SaveOptions.DisableFormatting)); }