使用linq的选择过程出现问题 [英] problem with select procedure using linq
问题描述
大家好,我的结构如下:
hi guys, I have the following structure:
var sessao = db.pr_ixxx_sessao_cliente(2, login, senha, null, null, null, null, null, null, null);
foreach (var contador in sessao)
{
objcliente.clienteID = int.Parse(contador.is_cliente.ToString());
objcliente.estoqueEnsaios = int.Parse(contador.et_ensaio.ToString());
objcliente.Estoque24horas = int.Parse(contador.et_24h.ToString());
objcliente.EstoqueCam = int.Parse(contador.et_cam.ToString());
objcliente.login = contador.nm_email.ToString();
}
我在foreach中遇到错误
说它不能与Object类型的参数一起使用,因为没有发布任何定义来获取枚举器,
我要返回表格的一行,
I am getting an error in foreach
saying it can not operate with parameters of type Object, because no definition is published to get enumerator,
I am returning one row of the table,
know someone help me?
推荐答案
尝试以下操作:
Try the following:
foreach (var contador in (IEnumerable)sessao)
由于我对db.pr_ixxx_sessao_cliente应该返回什么一无所知,所以这只是一个猜测.如果对象的实际类型是IEnumerable,则它应该可以工作.但是,您可能还必须将contador转换为正确的类型.现在,可以通过执行以下操作同时实现这两个功能:
Since I know nothing about what db.pr_ixxx_sessao_cliente is suppose to return, this is just a guess. If the actual type of the object is IEnumerable, it should work. However, you will probably also have to cast contador to the right type. Now may be able to do both by doing the following:
foreach (var contador in (IEnumerable<sesssaotype>)sessao)</sesssaotype>
这篇关于使用linq的选择过程出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!