简体   繁体   中英

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

The data reader is incompatible with the specified 'AriaSalesmanagmentModel.VW_Sale'. A member of the type, 'ID', does not have a corresponding column in the data reader with the same name.

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

I would also recommend you not pass dates as strings - and certainly not as nvarchar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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