Skip to content

Instantly share code, notes, and snippets.

@KevM
Created November 29, 2011 21:42
Show Gist options
  • Select an option

  • Save KevM/1406672 to your computer and use it in GitHub Desktop.

Select an option

Save KevM/1406672 to your computer and use it in GitHub Desktop.
Clarify Extension Methods
public static class ClarifyGenericExtensions
{
public static ClarifyGeneric Filter(this ClarifyGeneric generic, Func<FilterExpression, Filter> filterFunction)
{
var filterExpression = new FilterExpression();
var filter = filterFunction(filterExpression);
generic.Filter.AddFilter(filter);
return generic;
}
public static ClarifyGeneric TraverseWithFields(this ClarifyGeneric generic, string relationName, params string[] fields)
{
if (fields == null || fields.Length < 1)
fields = new[] {"objid"};
var childGeneric = generic.Traverse(relationName);
childGeneric.DataFields.AddRange(fields);
return childGeneric;
}
}
@KevM

KevM commented Nov 29, 2011

Copy link
Copy Markdown
Author

TraverseWithFields : Changes code like this

var siteGeneric = userGeneric.Traverse("supp_person_off2site");
siteGeneric.DataFields.Add("objid");

to this

var siteGeneric = userGeneric.TraverseWithFields("supp_person_off2site");

or the equivalent

var siteGeneric = userGeneric.TraverseWithFields("supp_person_off2site", "objid");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment