0
I’m having problems performing a select (using LINQ) in a View in SQL Server 2012. The values stored in the bank are as below:
ID_Acomp ID_Pessoa Nome Data
26 300 MONTEIRO 01-01-2016
27 300 MONTEIRO 02-02-2016
28 300 MONTEIRO 03-03-2016
When I perform select in SQL Manager, the values return perfectly. But when I do the same select through LINQ, the value of the last record is replicated over the other records above, and it looks like this:
ID_Acomp ID_Pessoa Nome Data
28 300 MONTEIRO 03-03-2016
28 300 MONTEIRO 03-03-2016
28 300 MONTEIRO 03-03-2016
The code I’m using in the application basically is this:
IQueryable<VW_PESSOA_ACOMPANHAMENTO> vwPessoaAcomp =
contexto.VW_PESSOA_ACOMPANHAMENTO.AsQueryable();
if (ID_Pessoa > 0)
{
vwPessoaAcomp = vwPessoaAcomp(p => p.ID_Pessoa == ID_Pessoa);
}
var retorno = (from A in vwPessoaAcomp
orderby A.ID_Acomp descending
select A).ToList();
Below is the code of my view:
SELECT A.ID_Acomp, P.ID_Pessoa, P.Nome, A.Data
FROM ACOMPANHAMENTO A, PESSOA P WHERE A.ID_ACOMP = P.ID_ACOMP
is mysql? which SQL is running in SQL Manager? if you can put the question!
– novic
Using SQL Server 2012
– Gleison França
Which SQL you use in SQL Manager?
– novic
Enter the code of your view, you post the select of sql. This will facilitate the help. You debugged the "return" to see if you generated the records the way you would like ?
– Almeida
The debug of the return from Linq yes, but I never debug in sql manager. When I run the select from the view in sql manager the return is correct.
– Gleison França
You are using the Entity framework?
– RodrigoTrevi