List<Object> arr= new List<Object>();
using (DataBaseDataContext db = new DataBaseDataContext())
{
//where like
arrR = (from o in db.table
where o.field.Contains("text")
//group
/*where o.field== "text"
group o.field1 new Obj (){
Attribute1 = o.field1,
Attribute2 = o.field2,
Attribute3 = o.field3
} into g
//orderby g.Key.field1
select g.Key).ToList();*/
select o).ToList();
}
Select
第一種方法如上
第二種方法
var result = (from p in db.table
select p);
if(true)
result = query.Where(o=>o.p.ID == 1);
var entity = query.select(o=>o.p.ID).FirstOrDefault();
想要串接多個條件
List<Object> arr= new List<Object>();
using (DataBaseDataContext db = new DataBaseDataContext())
{
arrR = (from o in db.table
where o.field.Contains("text") && o.field2 = false
select o).ToList();
}