Skip to content

Instantly share code, notes, and snippets.

@k4m4r82
Created August 22, 2017 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k4m4r82/6398e259ef86dcf1a3386a2e3cd55215 to your computer and use it in GitHub Desktop.
Save k4m4r82/6398e259ef86dcf1a3386a2e3cd55215 to your computer and use it in GitHub Desktop.
using Dapper;
using log4net;
using WindowsServiceGammu.Model;
namespace WindowsServiceGammu.Repository
{
public interface ISiswaRepository
{
Siswa GetByNIS(string nis);
}
public class SiswaRepository : ISiswaRepository
{
private IDapperContext _context;
private ILog _log;
public SiswaRepository(IDapperContext context, ILog log)
{
this._context = context;
this._log = log;
}
public Siswa GetByNIS(string nis)
{
Siswa siswa = null;
try
{
var sql = @"select nis, nama
from siswa
where nis = @nis";
siswa = _context.db.QuerySingleOrDefault<Siswa>(sql, new { nis });
}
catch (Exception ex)
{
_log.Error("Error:", ex);
}
return siswa;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment