一段代码:
using (var dc = new Database())
{
var results = from a in dc.Article
where a.IdNeswpaper == 12
select new
{
a.Id,
};
dataGrid1.ItemsSource = results;
}
此查询在 Sql Profiler 中可见,但是:
int idNews = 12;
using (var dc = new Database())
{
var results = from a in dc.Article
where a.IdNeswpaper == idNews
select new
{
a.Id,
};
dataGrid1.ItemsSource = results;
}
不可见,两者都正确完成并显示数据。为什么第二个查询在 Sql Profiler 中不可见?有任何想法吗?