1、from 子句
var db = new NorthwindDataContext();
var categories = db.Session.CreateQuery("from Category")
.List<Category>();
foreach (var category in categories)
{
Console.WriteLine(category.CategoryName);
}
2、select 子句
var db = new NorthwindDataContext();
var categories = db.Session.CreateQuery("from Category as c select c.CategoryID, c.CategoryName")
.List<Category>();
foreach (var category in categories)
{
Console.WriteLine(category.CategoryName);
}
3、where 子句
var db = new NorthwindDataContext();
var categories = db.Session.CreateQuery(@"from Category as c
where c.CategoryID > 1
select c.CategoryID, c.CategoryName")
.List<Category>();
foreach (var category in categories)
{
Console.WriteLine(category.CategoryName);
}