Skip to content

Instantly share code, notes, and snippets.

@pdoran
Last active August 29, 2015 14:06
Show Gist options
  • Save pdoran/a382e6c373e3b9a02248 to your computer and use it in GitHub Desktop.
Save pdoran/a382e6c373e3b9a02248 to your computer and use it in GitHub Desktop.
//An outline example
public string GetSomethingFromDBAndFormat(Guid id){
var obj = Session.Get<Something>(id);
var formatString = GetNameFormat(obj);
formatString += GetNamesFromChildren(obj);
return formatString;
}
private string GetNameFormat(Something obj){
var formatString = "";
if(obj!=null && !string.IsNullOrEmpty(obj.Name)) {
formatString += string.Format("Name: {0}",obj.Name);
}
return formatString;
}
private string GetNamesFromChildren(Something obj){
var formatString = "";
if(obj!=null && obj.Children!=null) {
formatString = string.Join(" Child: ",
obj.Children.Select(c=> GetNameFormat(c))
);
}
return formatString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment