0
I am implementing a method that performs a call to another method that should return one IEnumerable<TEntidade>
. However, when returning from this list the method that started the call simply ends its execution without continuing to read the following code.
Debugging, I can access the query variable value within the scope of the List method.
Follow below example code. After the line var x = Listar();
the code ends its execution.
public void DoSomething()
{
//Some code here
var x = Listar();
//Some code here
}
public IEnumerable<ModelEntities> Listar()
{
var _c = new SMSEntities();
var query = //query Linq
select new ModelEntities
{
//inicializando campos
};
return query;
}
Have you tried debugging using breakpoints?
– mutlei
@mutlei, the purification that I mentioned in the code is using breakpoints.
– Vinícius
Ever tried to make
printf
s (or the equivalent in C#, which I don’t know) in parts of the code to know where it goes?– mutlei
Yes. When finishing the execution of the List method, it finishes the execution of the Dosomething method
– Vinícius
Are there any exceptions to be released? already seen in windows Event Viewer?
– Carlos Martins
Explicit exception is not released. I can even view the query data. If I give a tolist inside the List method I have the list of objects from the database. I will check now in the Viewer Event
– Vinícius
I returned EF6 to EF5 and the code worked without any problems. I will keep the question because I have not yet found the explanation for such, perhaps incompatibility with the Windowsservice.
– Vinícius
Downgrading the EF version doesn’t make any sense... probably there is some other problem, which you can’t see, outside the code posted.
– Miguel Angelo
When working with asynchronous methods (i.e.
async
/await
) this type of mysterious code interruption is very common. for example, when it is not usedawait
to call a methodasync
, ai you are debugging the body of the async method, and after a call await, nothing of the execution continue... hehe... type was already right!– Miguel Angelo
@Miguelangelo, thanks for the information, very useful. However, was not using the resource of asymptomatic methods in this case. I still can’t connect the EF downgrade to solve the problem.
– Vinícius
Ever tried to return as an anonymous type?
– MMalke