示例#1
0
 //get log record by id
 public LogData GetById(int id)
 {
     LogData data = new LogData();
     using (IDbConnection db = new SqlConnection(ConStr))
     {
         data = db.Query<LogData>("Select * from ActLogs where id=@ID", new {id}).FirstOrDefault();
     }
     return data;
 }
示例#2
0
        string ConStr = "meh"; //set connection string to db

        #endregion Fields

        #region Methods

        //write log record
        public bool DoLog(LogData data)
        {
            try
            {
                using (IDbConnection db = new SqlConnection(ConStr))
                {
                    var sqlQuery = "INSERT INTO ActLogs (ActLog) VALUES(@actLog); SELECT CAST(SCOPE_IDENTITY() as int)";
                    int? logId = db.Query<int>(sqlQuery, data).FirstOrDefault();
                }
                return true;
            }
            catch
            {
                return false;
            }
        }