-
-
Save islaytitans/78485d71954b09d29901 to your computer and use it in GitHub Desktop.
How to query data from xDB from facets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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