views:

112

answers:

1

I am reading up on the entity framework and the author is explaining ESQL, canonical functions, and Linq. he does not explain what canonical functions are and why they are needed. The code that he uses in the book can be easily converted to Linq. Where do canonical functions play in the Entity framework? Can I use canonical functions instead of linq and EQSL? What are the pros/cons of canonical functions.

canonical function

var query = context.question
            .Where(c => c.question_id == 1)
            .Select((c) => new { c.question_id });

Linq

var query = from p in context.question
                    where p.question_id == 1
                    select new { p, p.question_title};
+1  A: 

No, they are just the same, they will compile into the (more or likely) same bytecode; yet sometimes just chaining your commands is easier/more clear when writing your code.

Jan Jongboom