示例#1
0
        /// <summary>
        /// Returns the attribute name of the id of the entity if it doesn't follow the standard (logicalName + id) rule, or null
        /// </summary>
        /// <param name="logicalName"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static string GetIrregularIdAttributeName(string logicalName, IEntityHelperConfig config = null)
        {
            string name;

            switch (logicalName)
            {
            case "activitypointer":
            case "appointment":
            case "bulkoperation":
            case "campaignactivity":
            case "campaignresponse":
            case "email":
            case "fax":
            case "incidentresolution":
            case "letter":
            case "opportunityclose":
            case "phonecall":
            case "quoteclose":
            case "recurringappointmentmaster":
            case "serviceappointment":
            case "task":
                name = "activityid";
                break;

            default:
                name = (config ?? DLaBXrmConfig.EntityHelperConfig).GetIrregularIdAttributeName(logicalName);
                break;
            }

            return(name);
        }
示例#2
0
        /// <summary>
        /// Gets the Primary Field (name) info.
        /// </summary>
        /// <param name="logicalName">Name of the logical.</param>
        /// <param name="config">Interface for handling irregular primary attribute names.</param>
        /// <returns></returns>
        public static PrimaryFieldInfo GetPrimaryFieldInfo(string logicalName, IEntityHelperConfig config = null)
        {
            var info = new PrimaryFieldInfo();

            switch (logicalName)
            {
            case "businessunitnewsarticle":
                info.AttributeName = "articletitle";
                info.MaximumLength = 300;
                break;

            case "transactioncurrency":
                info.AttributeName = "currencyname";
                break;

            case "customerrelationship":
                info.AttributeName = "customerroleidname";
                info.ReadOnly      = true;
                info.IsAttributeOf = true;
                break;

            case "importjob":
                info.AttributeName = "data";
                info.MaximumLength = 1073741823;
                break;

            case "transformationparametermapping":
                info.AttributeName = "data";
                info.MaximumLength = 500;
                break;

            case "activitymimeattachment":
                info.AttributeName = "fileName";
                info.MaximumLength = 255;
                break;

            case "contact":
            case "systemuser":
            case "lead":
                info.AttributeName = "fullname";
                info.BaseAttributes.Add("firstname");
                info.BaseAttributes.Add("lastname");
                if (logicalName == "lead")
                {
                    info.BaseAttributes.Add("companyname");
                }
                info.ReadOnly = true;
                break;

            case "solution":
            case "publisher":
                info.AttributeName = "friendlyname";
                break;

            case "account":
            case "asyncoperation":
            case "bulkdeleteoperation":
            case "businessunit":
            case "calendar":
            case "calendarrule":
            case "campaign":
            case "competitor":
            case "connection":
            case "connectionrole":
            case "constraintbasedgroup":
            case "contracttemplate":
            case "convertrule":
            case "convertruleitem":
            case "customeraddress":
            case "discounttype":
            case "duplicaterule":
            case "emailserverprofile":
            case "entitlement":
            case "entitlementchannel":
            case "entitlementtemplate":
            case "entitlementtemplatechannel":
            case "equipment":
            case "fieldsecurityprofile":
            case "goalrollupquery":
            case "import":
            case "importfile":
            case "importmap":
            case "invoice":
            case "mailbox":
            case "mailmergetemplate":
            case "metric":
            case "opportunity":
            case "organization":
            case "pluginassembly":
            case "plugintype":
            case "pricelevel":
            case "privilege":
            case "processsession":
            case "product":
            case "publisheraddress":
            case "queue":
            case "quote":
            case "relationshiprole":
            case "report":
            case "resource":
            case "resourcegroup":
            case "resourcespec":
            case "role":
            case "routingrule":
            case "routingruleitem":
            case "salesliterature":
            case "salesorder":
            case "savedquery":
            case "savedqueryvisualization":
            case "sdkmessage":
            case "sdkmessageprocessingstep":
            case "sdkmessageprocessingstepimage":
            case "service":
            case "serviceendpoint":
            case "sharepointdocumentlocation":
            case "sharepointsite":
            case "site":
            case "sla":
            case "systemform":
            case "team":
            case "territory":
            case "uom":
            case "uomschedule":
            case "userform":
            case "userquery":
            case "userqueryvisualization":
            case "webresource":
                info.AttributeName = "name";
                break;

            case "list":
                info.AttributeName = "listname";
                info.MaximumLength = 128;
                break;

            case "activityparty":
                info.AttributeName = "partyidname";
                info.MaximumLength = 400;
                info.ReadOnly      = true;
                info.IsAttributeOf = true;
                break;

            case "invoicedetail":
            case "opportunityproduct":
            case "productpricelevel":
            case "quotedetail":
            case "salesorderdetail":
                info.AttributeName = "productidname";
                info.ReadOnly      = true;
                info.IsAttributeOf = true;
                break;

            case "socialprofile":
                info.AttributeName = "profilename";
                break;

            case "postfollow":
                info.AttributeName = "regardingobjectidname";
                info.ReadOnly      = true;
                info.IsAttributeOf = true;
                info.MaximumLength = 4000;
                break;

            case "columnmapping":
                info.AttributeName = "sourceattributename";
                info.MaximumLength = 160;
                break;

            case "processstage":
                info.AttributeName = "stagename";
                break;

            case "activitypointer":
            case "annotation":
            case "appointment":
            case "bulkoperation":
            case "campaignactivity":
            case "campaignresponse":
            case "email":
            case "fax":
            case "incidentresolution":
            case "letter":
            case "opportunityclose":
            case "orderclose":
            case "phonecall":
            case "quoteclose":
            case "recurringappointmentmaster":
            case "serviceappointment":
            case "socialactivity":
            case "task":
                info.AttributeName = "subject";
                info.MaximumLength = 200;
                break;

            case "teamtemplate":
                info.AttributeName = "teamtemplatename";
                break;

            case "post":
            case "postcomment":
            case "tracelog":
                info.AttributeName = "text";
                info.MaximumLength = 1000;
                break;

            case "contract":
            case "contractdetail":
            case "goal":
            case "incident":
            case "kbarticle":
            case "kbarticlecomment":
            case "kbarticletemplate":
            case "queueitem":
            case "salesliteratureitem":
            case "subject":
            case "template":
                info.AttributeName = "title";
                break;

            default:
                if (logicalName.Contains('_'))
                {
                    info.AttributeName = logicalName.SubstringByString(0, "_") + "_name";
                }
                else
                {
                    info.AttributeName = null;
                }

                info = (config ?? DLaBEntityHelperConfig.Config).GetIrregularPrimaryFieldInfo(logicalName, info) ?? info;
                break;
            }

            return(info);
        }
示例#3
0
        /// <summary>
        /// Defaults the entity name of all created entities.
        /// </summary>
        /// <param name="getName">function to call to get the name for the given Entity and it's Primary Field Info</param>
        /// <param name="config">Entity Help settings to define primary attributes</param>
        /// <returns></returns>
        public TDerived WithEntityNameDefaulted(Func <Entity, PrimaryFieldInfo, string> getName, IEntityHelperConfig config = null)
        {
            CreateFuncs.Add((s, e) =>
            {
                var logicalName = e.LogicalName;
                if (!string.IsNullOrWhiteSpace(logicalName))
                {
                    var info = GetPrimaryFieldInfo(logicalName, config);

                    SetName(e, info, getName);
                }
                return(s.Create(e));
            });
            return(This);
        }
示例#4
0
 /// <summary>
 /// Gets the primary field information.
 /// </summary>
 /// <param name="logicalName">Logical name of the entity.</param>
 /// <param name="config">Entity Help settings to define primary attributes</param>
 /// <returns></returns>
 public virtual PrimaryFieldInfo GetPrimaryFieldInfo(string logicalName, IEntityHelperConfig config = null)
 {
     return(EntityHelper.GetPrimaryFieldInfo(logicalName, config ?? new PrimaryNameProviderConfig()));
 }
示例#5
0
 /// <summary>
 /// Returns the attribute name of the id of the entity if it doesn't follow the standard (logicalName + id) rule, or null
 /// </summary>
 /// <typeparam name="T">Entity Type to use Reflection to lookup the entity logical name for</typeparam>
 /// <param name="config">Interface for handling irregular primary attribute names.</param>
 /// <returns></returns>
 public static string GetIrregularIdAttributeName <T>(IEntityHelperConfig config = null) where T : Entity
 {
     return(GetIrregularIdAttributeName(GetEntityLogicalName <T>(), config));
 }
示例#6
0
 /// <summary>
 /// Returns the attribute name of the id of the entity using late bound approach
 /// </summary>
 /// <param name="logicalName"></param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static string GetIdAttributeName(string logicalName, IEntityHelperConfig config = null)
 {
     return(GetIrregularIdAttributeName(logicalName, config) ?? logicalName + "id");
 }