实体框架错误 [英] error in entity frame work

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

问题描述

我在实体框架中编写SQl查询

I Write A SQl Query In Entity Frame Work

var query1 = database.Database.SqlQuery<customer>("select name from customer where shomaremoshtare ='" + txt_shomaremoshtare.Text.Trim() + "'");

当我运行此代码时,我给出此错误
在此处输入图片描述

When I Run This Code I Give This Error enter image description here

推荐答案

您只返回所选实体的名称,请尝试返回所有字段,如下所示:

You are returning only the name of the entity in your select, try to return all the fields like this:

var query1 = database.Database.SqlQuery<customer>("select * from customer where shomaremoshtare ='" + txt_shomaremoshtare.Text.Trim() + "'");

预期类型是客户而不仅仅是名称。

The type expected is customer not just a name.

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

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