返回表功能有误 [英] Return Table has Error In Function

查看:64
本文介绍了返回表功能有误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public Table1 search()
 {

     Table1 t = new Table1();

     var qq = from c in DataBase.Table1s select c;


     return qq;//Error Cannot Convert????how to resolve this

 }

推荐答案

您将在函数签名中返回Table1.因此,尝试将返回变量"qq"强制转换为表1.与return(Table1)qq; 类似,您正在函数签名中返回Table1.因此,尝试将返回变量"qq"强制转换为表1.就像"return(Table1)qq;"一样.
You are returning Table1 in your function signature. So, try casting the return var ''qq'' to Table1. Like return (Table1)qq;You are returning Table1 in your function signature. So, try casting the return var ''qq'' to Table1. Like "return (Table1)qq;"


我认为Table1是模型中的一个实体.您必须从表中选择一行以将其返回.

试试这个

I think Table1 is an entity in your model. You have to select a row from the table to return it.

Try this

private Table1 Result()
{
Table1 t = new Table1();
t =
DataBase.Table1s.Single(k=>k.Id>0);
 
}


嘿,
您正在尝试返回多个表

从DataBase.Table1s中的c选择c;

该语句将仅返回表列表
使用
修改代码

hey ,
you are trying to return multiple tables

from c in DataBase.Table1s select c;

this statement will return list of tables just
modify your code with


public Table1 search()
 {

     Table1 t = new Table1();

     t  = (from c in DataBase.Table1s select c).ToList().FirstOrDefault();


     return t;//Error Cannot Convert????how to resolve this

 }


这篇关于返回表功能有误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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