A library to create QueryExpression the fluent way
You can rely on :
- EarlyBoundGenerator from Daryl LaBar to create the Early Bound Entities to be used with this project (optional)
- LateBoundConstantsGenerator from Jonas Rapp to create Late Bound constants to be used with this projet (optional)
var query = new Query<Account>()
.Top(10)
.Distinct()
.NoLock()
.SetPaging(1, 100, true);
var earlyBoundQuery = new Query<Account>()
.Select(Account.Fields.Name, Account.Fields.AccountNumber);
var earlyBoundQuery2 = new Query<Account>()
.Select(a => new { a.Name, a.AccountNumber});
var lateBoundQuery = new Query("account")
.Select("name", "accountnumber");
var earlyBoundQuery = new Query<Account>()
.Select(Account.Fields.Name, Account.Fields.AccountNumber)
.WhereEqual(Account.Address1_City, "Paris");
var lateBoundQuery = new Query("account")
.Select("name", "accountnumber")
.WhereEqual("address1_city", "Paris");
var earlyBoundQuery = new Query<Account>()
.Select(Account.Fields.Name, Account.Fields.AccountNumber)
.AddFilters(new Filter(LogicalOperator.Or)
.WhereEqual(Account.Address1_City, "Paris")
.WhereEqual(Account.Address1_City, "Nantes")
);
var lateBoundQuery = new Query("account")
.Select("name", "accountnumber")
.AddFilters(new Filter(LogicalOperator.Or)
.WhereEqual("address1_city", "Paris")
.WhereEqual("address1_city", "Nantes")
);
var earlyBoundQuery = new Query<Account>()
.Select(Account.Fields.Name, Account.Fields.AccountNumber)
.AddLink<Contact>(new Link(Contact.Fields.ParentCustomerId, Account.Fields.AccountId, JoinOperator.LeftOuter)
.SetAlias("cont")
.Select(Contact.Fields.Fullname)
.WhereEqual(Contact.Address1_City, "Paris")
.WhereEqual(Contact.Address1_City, "Nantes")
);
var lateBoundQuery = new Query("account")
.Select("name", "accountnumber")
.AddLink(new Link(Contact.EntityLogicalName, Contact.Fields.ParentCustomerId, Account.Fields.AccountId, JoinOperator.LeftOuter)
.SetAlias("cont")
.Select("fullname")
.WhereEqual("address1_city", "Paris")
.WhereEqual("address1_city", "Nantes")
);
var earlyBoundQuery = new Query<Account>()
.Select(Account.Fields.Name, Account.Fields.AccountNumber)
.Order(Account.Fields.Name, OrderType.Ascending);
var lateBoundQuery = new Query("account")
.Select("name", "accountnumber")
.Order("name", OrderType.Ascending);
Either retrieve QueryExpression
property or use one of the method to get records
var qe = new Query("account").QueryExpression;
List<Account> records = new Query<Account>().GetAll(iOrganizationService);
Account record = new Query<Account>().GetFirst(iOrganizationService);
Account record = new Query<Account>().GetFirstOrDefault(iOrganizationService);
Account record = new Query<Account>().GetLast(iOrganizationService);
Account record = new Query<Account>().GetLastOrDefault(iOrganizationService);
Account record = new Query<Account>().GetSingle(iOrganizationService);
Account record = new Query<Account>().GetSingleOrDefault(iOrganizationService);
EntityCollection records = new Query<Account>().GetRecords(iOrganizationService);