简体   繁体   English

在实体框架中使用存储过程时出错?

[英]Error in use of stored procedure In Entity Framwork?

I want use this stored procedure in Entity Framework我想在实体框架中使用这个存储过程

CREATE Procedure [dbo].[GetSood]
   @datefrom nvarchar(15),
  @dateto nvarchar(15)
AS 
    SELECT Price, Numbers, PriceTotal 
    FROM VW_Sale  
    WHERE DateCreate >= @datefrom 
      AND DateCreate <= @dateto  
      AND IsSale = 1 
      AND PayType = 2;

I add this procedure in the model but when run show this error我在 model 中添加了此过程,但运行时显示此错误

The data reader is incompatible with the specified 'AriaSalesmanagmentModel.VW_Sale'.数据读取器与指定的“AriaSalesmanagmentModel.VW_Sale”不兼容。 A member of the type, 'ID', does not have a corresponding column in the data reader with the same name.类型的成员“ID”在数据读取器中没有同名的对应列。

and my code is:我的代码是:

public List<DAL.VW_Sale> GetSood(string dateFrom, string dateTo)
{
   DAL.AriaSalestEntities objAria = new AriaSalestEntities();

   var sood = from s in objAria.GetSood(dateFrom, dateTo) select s;
   return sood.ToList();
}

please help me?请帮我?

If your entity is based on all the columns in VW_Sale, then you need to have SELECT * FROM VW_Sale如果您的实体基于 VW_Sale 中的所有列,那么您需要有SELECT * FROM VW_Sale

I would also recommend you not pass dates as strings - and certainly not as nvarchar.我还建议您不要将日期作为字符串传递——当然也不要作为 nvarchar 传递。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM