Skip to content

Instantly share code, notes, and snippets.

@islaytitans

islaytitans/GetSampleOrders.cs Secret

Last active Feb 27, 2016
Embed
What would you like to do?
How to query data from xDB from facets
public class GetSampleOrders : ReportProcessorBase
{
private readonly QueryBuilder _contactsQueryBuilder = new QueryBuilder()
{
collectionName = "Contacts", // Name of the collection containing contacts in MongoDb
QueryParms =
{
{ "_id", "@contactid" },
},
Fields =
{
"_id",
"KeyInteractions_SampleOrder", // path so the Sample Order Element in our custom xDB Facet
"System_VisitCount"
}
};
public override void Process(ReportProcessorArgs args)
{
Guid contactId = args.ReportParameters.ContactId;
DataTable contactQueryExpression =
base.GetTableFromContactQueryExpression(_contactsQueryBuilder.Build(), contactId, new Guid?());
Assert.IsTrue(contactQueryExpression.Rows.Count >= 1,
string.Format("Contact with id {0} was not found.", (object) contactId));
int? nullable = DataRowExtensions.Field<int?>(contactQueryExpression.Rows[0], "System_VisitCount");
if (nullable == null)
Log.Debug(string.Format("No VisitCount exists for contact: {0}", (object) contactId));
args.QueryResult = contactQueryExpression;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.