Exemple #1
0
 /// <summary>
 /// Returns the Primary Name for the given entity logical name
 /// </summary>
 /// <param name="logicalName"></param>
 /// <returns></returns>
 public override string GetPrimaryName(string logicalName)
 {
     if (NamelessEntities.Contains(logicalName))
     {
         return(string.Empty);
     }
     return(NonStandardNames.TryGetValue(logicalName, out var name) ? name : EntityHelper.GetPrimaryFieldInfo(logicalName, new DefaultConfig()).AttributeName);
 }
        /// <summary>
        /// Returns the Primary Name for the given entity logical name
        /// </summary>
        /// <returns></returns>
        public override string GetPrimaryName <T>()
        {
            var field = typeof(T).GetField(PrimaryNameFieldName);

            if (field == null)
            {
                if (NamelessEntities.Contains(EntityHelper.GetEntityLogicalName <T>()))
                {
                    return(string.Empty);
                }
                throw new Exception($"Type \"{typeof(T).FullName}\" does not contain a field with the name \"{PrimaryNameFieldName}\"!  Consider using the Early Bound Generator to generate this value or using the PrimaryNameViaNonStandardNamesProvider and providing a list of non-standard names via the config.");
            }

            return((string)field.GetValue(null));
        }