private string GetNotesField(IBusinessObject b) { var query = from f in b.FieldNames let len = f.Length let size = b.GetFieldMaxLength(f) ?? 0 where f.EndsWith("Notes") orderby size descending, f.Length ascending select f; return(query.FirstOrDefault()); }
// if the bo has a usable notes field, and the truncated field string // will fit, add the truncated field string to the notes internal void Finish() { // find the notes field string notesField = GetNotesField(bo); string truncationNotes = GetTruncatedFields(); // if the field has enough room, append if (notesField != null) { string existingNotes = (bo[notesField] as string) ?? string.Empty; if (existingNotes.Length + truncationNotes.Length <= bo.GetFieldMaxLength(notesField)) { bo[notesField] = existingNotes + truncationNotes; } } }