3

What I need to do is select list of nested elements, here is my query which returns IEnumerable<IEnumerable<object>> here is my linq expression:

from a in (questions.Select(x => x.AnswerList).ToList())
                           select a.Select(x => x.AnswerBasicViewModel);

How should I do that to make it return only IEnumerable<object> instead of IEnumerable<IEnumerable<object>>?

Just to be clear in my sample I would like to get IEnumerable<AnswerBasicViewModel>.


You should run your time consuming code in a separated thread :

myFunction(){
    myLabel.setText("Started");
    new Thread(new Runnable(){
        @Override
        public void run() {
             //time consuming code which creates object of another class
        }
    }).start();

}
4

2 に答える 2

8

使用SelectMany演算子:

from q in questions
from a in q.AnswerList
select a.AnswerBasicViewModel

または単に

questions.SelectMany(q => q.AnswerList)
         .Select(a => a.AnswerBasicViewModel)
于 2013-09-13T10:06:50.130 に答える