Habanero.Smooth.IdentityAutoMapper.MapIdentity C# (CSharp) Method

MapIdentity() public method

Map the Identity for the given ClassDef
public MapIdentity ( ) : IPrimaryKeyDef
return IPrimaryKeyDef
        public IPrimaryKeyDef MapIdentity()
        {
            var classDef = this.ClassDef;

            var primaryKeyDef = GetPrimaryKeyDef(classDef);
            if (primaryKeyDef == null)
            {
                var propDef = GetPrimaryKeyPropDef();
                if (propDef == null) return null;
                var keyDef = new PrimaryKeyDef {propDef};

                keyDef.IsGuidObjectID = IsGuidObjectID(propDef);
                classDef.PrimaryKeyDef = keyDef;
            }

            return classDef.PrimaryKeyDef;
        }

Usage Example

        /// <summary>
        /// gets the Primary Key Def for a ClassDef
        /// </summary>
        /// <param name="classDef"></param>
        /// <returns></returns>
        public static IPrimaryKeyDef MapIdentity(this IClassDef classDef)
        {
            if (classDef == null) return null;
            var autoMapper = new IdentityAutoMapper(classDef);

            return autoMapper.MapIdentity();
        }
All Usage Examples Of Habanero.Smooth.IdentityAutoMapper::MapIdentity