public List<Report> GetListReport(ReportEnums orderBy, string orderDirection, int page, int pageSize, out int totalRecords) { using (DataContext = new VfsCustomerServiceEntities()) { DataContext.Database.Connection.Open(); DbCommand cmd = DataContext.Database.Connection.CreateCommand(); cmd.CommandText = "spReportGetList"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("OrderBy", orderBy.ToString())); cmd.Parameters.Add(new SqlParameter("OrderDirection", orderDirection)); cmd.Parameters.Add(new SqlParameter("Page", page)); cmd.Parameters.Add(new SqlParameter("PageSize", pageSize)); var totalCountParam = new SqlParameter("TotalRecords", 0) { Direction = ParameterDirection.Output }; cmd.Parameters.Add(totalCountParam); List<Report> tasks; using (var reader = cmd.ExecuteReader()) { tasks = reader.MapToList<Report>(); } //Access output variable after reader is closed totalRecords = (totalCountParam.Value == null) ? 0 : Convert.ToInt32(totalCountParam.Value); return tasks; } }
public List<CustomerLog> getListCustomerVIPType() { using (db = new VfsCustomerServiceEntities()) { var result = (from cl in db.CustomerLogs orderby cl.Total_Download descending, cl.Total_Login descending, cl.CustomerId ascending select cl).ToListAsync(); return result.Result; } }
public static async Task<List<CustomerCustom>> getListCustomerVIPType() { using (db = new VfsCustomerServiceEntities()) { var result = await (from c in db.Customers where c.VType == true select new CustomerCustom { CustomerId = c.CustomerId, Mobile = c.Mobile }).ToListAsync(); return result; } }
public void InsertReport(Report rp) { using (DataContext = new VfsCustomerServiceEntities()) { try { DataContext.Reports.Add(rp); DataContext.SaveChanges(); } catch (Exception) { } } }