public async Task <IEnumerable <AcctN> > GetAcctNAsync(string usernames, DateTime?beginTime, DateTime?endTime) { if (String.IsNullOrEmpty(usernames)) { //throw new ArgumentNullException(nameof(usernames)); usernames = usernames ?? ""; } beginTime = beginTime ?? DateTime.Parse("1753-1-1"); endTime = endTime ?? DateTime.MaxValue; var connection = _context.Database.GetDbConnection(); await connection.OpenAsync(); var command = connection.CreateCommand(); command.CommandText = "select totalinput, totaloutput,username from dbo.GetAccountings(@usernames, @begintime, @endtime)"; command.Parameters.Add(new SqlParameter("@usernames", usernames)); command.Parameters.Add(new SqlParameter("@begintime", beginTime)); command.Parameters.Add(new SqlParameter("@endtime", endTime)); var reader = await command.ExecuteReaderAsync(); var acctns = AcctN.GetFromReader(reader).ToArray(); connection.Close(); return(acctns); }
public async Task <IEnumerable <AcctN> > GetAcctNAsync(DateTime?beginTime, DateTime?endTime) { beginTime = beginTime ?? DateTime.Parse("1753-1-1"); endTime = endTime ?? DateTime.MaxValue; var connection = _context.Database.GetDbConnection(); await connection.OpenAsync(); var command = connection.CreateCommand(); command.CommandText = "select totalinput, totaloutput,username from dbo.GetAccountingsWithoutUsernames(@begintime, @endtime)"; command.Parameters.Add(new SqlParameter("@begintime", beginTime)); command.Parameters.Add(new SqlParameter("@endtime", endTime)); var reader = await command.ExecuteReaderAsync(); var acctns = AcctN.GetFromReader(reader).ToArray(); return(acctns); }