我需要将一个sql查询传递给c#。在c#中建立一个sql查询#
下面是该查询:
select
T010.A010_nom_ent A010_nom_ent
from
T010_ENTIDADE T010,
T016_USUARIO T016
left outer join
T307_CELULA_USUARIO T307 ON T307.A306_seq_celula = 0
and T307.A016_cod_usuario = T016.A016_cod_usuario
where
T010.A010_cod_entidade = T016.A016_cod_usuario
order by 1
和代码是在这里:
public List<Entidade> ListarUsuariosCelula()
{
List<Entidade> lstEntidades = null;
try
{
oInvitroEntities = new InvitroEntities();
lstEntidades = (***here is where i want to put the query***)
return lstEntidades;
}
catch (Exception ex)
{
LogErro.Trace(ex);
throw ex;
}
finally
{
oInvitroEntities = null;
}
}
这里是什么,我想做的一个为例(我会把只是一块代码) :
try
{
oInvitroEntities = new InvitroEntities();
lstCelula = (from cel in oInvitroEntities.T306_CELULA
select new Celula { Codigo = cel.A306_seq_celula, Descricao = cel.A306_dsc_celula }).ToList();
return lstCelula;
}
什么是你的ORM?它是EntityFramework还是别的?你能告诉我们你的映射吗?而你的查询似乎不起作用。 –
它正在工作,我只需要将它传递给C#。其他的事情我要做我知道如何 – user3107374
通常查询被传递到SQL Server而不是其他方式....你的意思_pass一个SQL查询到C#._ – Steve