实体框架中使用存储过程中的错误? [英] Error in Use Store Procedure In Entity Framwork?

查看:92
本文介绍了实体框架中使用存储过程中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在实体框架中使用此存储过程

i want use this store procedure in entity framwork

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 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();
        }</dal.vw_sale>

推荐答案

通常,当存储过程返回的游标的列集与视图的列集不同时,就会出现此问题.
不同之处可能在于这些列的名称.请检查列名称在数据库和框架中是否相同.
检查您的框架是否有时会更新,Designer.cs不会对其进行更新.
This problem usually arises when the cursor returned by stored procedure has a set of columns that differs from the set of view''s columns.
The difference can be in names of these columns. Please check if the column name is the same in database and framework.
Check if your framework is updated sometimes Designer.cs will not update it.


这篇关于实体框架中使用存储过程中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆