public UnitOfWork(LarcContext context) { _context = context; Events = new EventRepository(_context); EventTypes = new EventTypeRepository(_context); Ministries = new MinistryRepository(_context); Podcasts = new PodcastRepository(_context); Preachers = new PreacherRepository(_context); }
public int ExecuteSql(string storedProcedureName, List <SqlParameter> listSqlParameter) { var context = new LarcContext(); using (var sqlConnection = new SqlConnection(context.Database.Connection.ConnectionString)) { sqlConnection.Open(); try { var command = new SqlCommand { CommandText = storedProcedureName, Connection = sqlConnection, CommandType = CommandType.StoredProcedure }; var resultParameter = command.CreateParameter(); resultParameter.ParameterName = "@result"; resultParameter.Direction = ParameterDirection.Output; resultParameter.DbType = DbType.Int32; resultParameter.Value = -1; if (listSqlParameter != null) { foreach (var parameter in listSqlParameter) { command.Parameters.Add(parameter); } command.Parameters.Add(resultParameter); } command.ExecuteNonQuery(); return((int)resultParameter.Value); } catch (Exception ex) { //Log.Error("ExecutePostSqlStoredProcedure - " + storedProcedureName, ex); } } return(-1); }
public Repository(LarcContext context) { Context = context; }