return (from term in dataContext.Terms< br /> where term.Name.StartsWith(text)
select term).ToDictionary(t => t.TermID, t => t.Name);
Whether the call will get every The entire content of each term, or just retrieve the TermID and Name fields from my data provider? In other words, if I write it like this, I will save my database traffic:
return (from term in dataContext.Terms
where term.Name.StartsWith (text)
select new {term.TermID, term.Name }).ToDictionary(t => t.TermID, t => t.Name);
In other words, yes, your second version will be more efficient.
div>
I am using Enumerable.ToDictionary to create a Dictionary from linq call:
return (from term in dataContext.Terms
where term.Name.StartsWith(text)
select term).ToDictionary(t => t.TermID, t => t.Name);
Whether the call will get each term Or just retrieve the TermID and Name fields from my data provider? In other words, if I write it like this, I will save my database traffic:
return (from term in dataContext.Terms
where term.Name.StartsWith (text)
select new {term.TermID, term.Name }).ToDictionary(t => t.TermID, t => t.Name);
p>
Enumerable.ToDictionary applies to IEnumerable objects. The first part of the statement “(from…choose terms”) is an IQueryable object. Queryable will look at the expression and build the SQL statement. Then it will convert it to IEnumerable to pass to ToDictionary().
In other words, yes, your second version will be more efficient.
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2698 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC