Exemplo n.º 1
0
        /// <summary>
        /// 取得数据库字段名称
        /// </summary>
        /// <param name="includeIdentityColumn">是否包含标识字段</param>
        /// <param name="includeTableName">是否包含表名</param>
        /// <returns></returns>
        public string[] GetColumnNames(bool includeIdentityColumn, bool includeTableName)
        {
            IEnumerable <KeyValuePair <string, DatabaseEntityPropertyAttribute> > temp = PropertyAttributeDict;

            if (!includeIdentityColumn)
            {
                temp = PropertyAttributeDict.Where(p => p.Value.IsPrimaryKey == false);
            }
            if (includeTableName)
            {
                return(temp.Select(p => DatabaseEntityAttribute.TableName + "." + p.Value.ColumnName).ToArray());
            }
            else
            {
                return(temp.Select(p => p.Value.ColumnName).ToArray());
            }
        }