Azavea.NijPredictivePolicing.Common.DB.DataClient.RowCount C# (CSharp) Method

RowCount() public static method

public static RowCount ( DbConnection conn, IDataClient client, string tablename ) : int
conn System.Data.Common.DbConnection
client IDataClient
tablename string
return int
        public static int RowCount(DbConnection conn, IDataClient client, string tablename)
        {
            try
            {
                string sql = string.Format("select count(1) from {0}", tablename);
                var cmd = client.GetCommand(sql, conn);
                return Utilities.GetAs<int>(cmd.ExecuteScalar(), -1);
            }
            catch (Exception ex)
            {
                _log.Error("Error while looking for table", ex);
            }
            return -1;
        }