Skip to content
Daryl LaBar edited this page Sep 2, 2024 · 20 revisions

Namespaces

Note: For simplicity sake, This documentation will refer to namespaces without the potential source prefix. So Source.DLaB.Xrm will just be listed as DLaB.Xrm

Features

Old Documentation

The main part of the library, with code that is applicable anywhere.

Classes

  • ActivePropertyInfo<T> where T : Entity and LateBoundActivePropertyInfo
    • Determines the Active Attribute info for the Entity. Includes the following information:
      • If the entity has the concept of being active (Some System Entities/activities don't have a clear concept of active/inactive).
      • AttributeName - The name of the active/inactive Attribute
      • ActiveState - The numerical value of active
      • NotActiveState - The numerical value of inactive
  • EntityHelper
    • Utility class to get an Entity Type from a name, and visa-versa, and for determining Entity Id Attribute Name
  • ExtendedOrganizationService
    • An IOrganizationService Wrapper that utilizes ExtendedOrganizationServiceSettings and an ITracingService to potentially log every request, timing it as well as parsing the queries into SQL
  • ExtendedTracingService
    • An ITracingService that is guaranteed to not throw an exception. Extremely helpful you have an error in your format string, rather than your plugin throwing an exception attempting to trace, it will just log that the format was incorrect
  • PrimaryFieldInfo
    • Contains information about the given Primary Name Field for an Entity. Includes the following information:
      • AttributeName
      • MaximumLength
      • BaseAttributes - the base attributes that make up the actual real name, so "firstname" and "lastname" for contact.
      • ReadOnly - whether the name field is [read only].
      • IsAttributeOf - If the name field is an is attribute of another entity, and therefor, not created via standard Early Bound Generation
  • QueryExpressionFactory / QuerySettings
    • Class for helping to create QueryExpressions that allows for some defaults to be set, like return the active entities only. Returns a TypedQueryExpression, making querying with QueryExpressions simpler/cleaner, since you can't create a QueryExpression for entity type "A", but then cast it in the RetireveMultiple to entity "B"

Extensions

The DLaB.Xrm Framework makes extremely heavy use of extension methods.

  • AddLink
    • Adds ability to add a LinkEntity to a LinkEntity or QueryExpression
var qe = QueryExpressionFactory.Create<Opportunity>();
// This AddLink will lookup the logical name of the Contact Entity when adding the link,
//     and it will only return the FirstName attribute
// If the joining attributes happened to be contactid for both, this could have just been written as :
// qe.AddLink<Contact>(Contact.Fields.ContactId, c => new { c.FirstName });
qe.AddLink<Contact>(Opportunity.Fields.ParentContactId, Contact.Fields.ContactId, c => new { c.FirstName });
var contact = service.GetFirstOrDefault(qe);
  • Aliased
    • Greatly Simplifies working aliased attributes with the following Entity Extensions:
      • AddAliased - Adds an entity or value to an entity, as if it was added via a query. Primarily used for unit testing.
      • GetAliasedEntity/GetAliasedValue - Allows for simple retrieval of Aliased Values, either as a whole entity, or particular attributes
      • HasAliasedAttribute - Performs a search of the entity to see if it has a specific Aliased Attribute
  • IsEqual
    • Allows for comparing the following types:
      • ColumnSet
      • FilterExpression
      • PagingInfo
      • QueryExpression
  • ById
    • Simplifies Retrieve calls, automatically casting the result, and allow for returning null if not found.
  • HasCondition
    • Searches QueryExpressions for the given Condition. Mostly used in testing.
  • OptimisticConcurrency
    • Preforms an Optimistic Update. If the entity's RowVersion doesn't match, the exception will be caught, and a reconciliation will be attempted before re-updating, indefinitely. Allows for skip update. Returns the entity whose Update Succeeded or null if the reconcileEntity function returned a null.
  • WhereEqual/WhereIn
    • These extensions can be some of the greatest simplifiers Query Expressions. Operates like QueryByAttribute, but is much more extensible, defaulting for equality, but allowing Condition Expressions.