In SalesLogix you can use the Sage.Platform.Repository.ICriteria class to query the entity model using standard ICriteria. One thing I have been asked in the past is how do you exclude certain conditions? A common example might be show me all of the non-closed tickets for a contact, where being closed is denoted by a status=”Closed”. In this scenario you only want a condition similar to status<>’closed’. This can be done using the .Not method which accepts as an input a standard parameter to exclude. Lets take a look at the code:
RepositoryHelper<Sage.Entity.Interfaces.ITicket> repository = EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.ITicket>(); Sage.Platform.Repository.ICriteria criteria = repository.CreateCriteria(); criteria.Add(repository.EF.Eq("Contact.Id", contact.Id.ToString())); criteria.Add(repository.EF.Not(repository.EF.Eq("StatusCode", "Closed"))); criteria.AddOrder(repository.EF.Desc("CreateDate")); result = criteria.List<Sage.Entity.Interfaces.ITicket>();
You can see the entity factory EF.Not used above which has passed in a EF.Eq condition looking for “Closed“ statuses. Now in this scenario I am using it assumes that StatusCode is storing “Closed” as text and not as the corresponding picklistid, which is not the standard OOTB SalesLogix behavior, but it should never the less demonstrate how to use the Not method to exclude a condition from your query result.