private static BillingModel GetPatBilling(string practice, int patNum) { var environment = PracticeManager.GetEnvironmentFromPractice(practice); var collection = new EntityCollection <PatBillingEntity>(); var bucket = new RelationPredicateBucket(); bucket.PredicateExpression.Add(PatBillingFields.Practice == practice); bucket.PredicateExpression.Add(PatBillingFields.BillTo == "P"); bucket.PredicateExpression.Add(PatBillingFields.PatNum == patNum); using (var adapter = AdapterFactory.CreateAdapter(MyNameSpace, environment)) { adapter.FetchEntityCollection(collection, bucket); } return(collection.Count < 1 ? null : new BillingModel(collection.Single())); }