Exemple #1
0
        /// <summary>
        /// 根据标识列的值返回整条数据
        /// </summary>
        /// <param name="IdentityValue">标识列的值</param>
        /// <returns></returns>
        internal DataTable SelectByIdentity(string IdentityValue)
        {
            string strTable     = "";
            string strCondition = "";

            try
            {
                //获取表名
                strTable = InternalBase <T> .GetTableName();

                //获取条件
                PropertyInfo[] pi = typeof(T).GetProperties();
                foreach (var item in pi)
                {
                    var temp = InternalBase <T> .GetColumnAttribute(item);

                    if (temp.Identity)
                    {
                        strCondition = item.Name + "='" + IdentityValue + "'";
                        break;
                    }
                }
                string sql = string.Format("select * from {0} where {1}", strTable, strCondition);
                return(dbl.ExecuteQuery(sql));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                return(null);
            }
        }