Exemple #1
0
        /// <summary>
        /// 获取模型信息方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="model"></param>
        /// <returns></returns>
        public static CodeFirstModel GetModelData<T>() where T : class 
        {
            CodeFirstModel codeFirstModel = new CodeFirstModel();
            codeFirstModel.ClassName = typeof(T).Name;
            var attr = CodeFirstAttributeHelper.GetCustomAttributeForClass<T, ModelAttributes.ItemDisplayNameAttribute>();

            if (attr != null)
            {
                codeFirstModel.Title = attr.DisplayName;
            }

            codeFirstModel.CodeFirstItemList = CodeFirstAttributeHelper.GetModelAttributeInfo<T>();

            return codeFirstModel;
        }
Exemple #2
0
        /// <summary>
        /// 获取模型信息方法
        /// </summary>
        /// <param name="modelType"></param>
        /// <returns></returns>
        public static CodeFirstModel GetModelData(Type modelType)
        {
            CodeFirstModel codeFirstModel = new CodeFirstModel();
            codeFirstModel.ClassName = modelType.Name;
            var attr = GetModelAttribute< ModelAttributes.ItemDisplayNameAttribute>(modelType);

            if (attr != null)
            {
                codeFirstModel.Title = attr.DisplayName;
            }

            codeFirstModel.CodeFirstItemList = CodeFirstAttributeHelper.GetModelAttributeInfo(modelType);

            return codeFirstModel;
        }