var emps = from x in DB
where x.ID = 100
select x;
var emp1 = from x1 in DB
where x1.ID = 100
select new { x };
What is difference between these two queries.
If we use anonymous-types is the performance will be increased or any other differences also there?
There is a big diffrence in those two queries. First returns collection of your entity, the second returns collection of anonymous-type which has a member called ‘x’ containing your entity.
Access to emps:
Access to emp1:
The first way is correct and natural, second is strange and in my opinion not really what you want to achive.
Also it’s not true, that using anonymous type here will increase performance. The object representing entity have to be build anyway, but this time you are getting it in less friendly form.