【发布时间】:2020-03-05 05:23:59
【问题描述】:
我正在创建 ASP.Net MVC WebApi 以将我的数据共享到银行。在这方面,我在测试我的 WebApi 时创建了一个 SQL 视图 位,它给出了一个 'System.OutOfMemoryException' 错误,因为我在 SQL 中有更多的 100 万条记录看法。 我的代码如下: - 这是我的控制器
public class InvoiceController : ApiController
{
public IEnumerable<VBank_invoice> Get()
{
using (kmcEntities entities = new kmcEntities())
{
return entities.VBank_invoice.ToList();
}
}
public VBank_invoice Get(string consumer)
{
using (kmcEntities entities = new kmcEntities())
{
return entities.VBank_invoice.FirstOrDefault(e => e.consumer_no == consumer);
}
}
}
My SQL 视图类
public partial class VBank_invoice
{
public int sno { get; set; }
public string consumer_no { get; set; }
public string consumer_name { get; set; }
public string consumer_address { get; set; }
public string billing_month { get; set; }
public Nullable<decimal> current_Charges { get; set; }
public Nullable<decimal> outstanding_Arrears { get; set; }
public Nullable<decimal> Arrears_15 { get; set; }
public Nullable<decimal> part_payment_arrears { get; set; }
public string billing_period_code { get; set; }
public string consumer_checkdigit { get; set; }
public Nullable<System.DateTime> due_date { get; set; }
}
这是我的 Model.Context.cs 文件
public partial class kmcEntities : DbContext
{
public kmcEntities()
: base("name=kmcEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<VBank_invoice> VBank_invoice { get; set; }
}
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 asp.net-web-api asp.net-web-api2 sql-view