枫中稻草
想要的话,就去争取

1.   选择:Select

  a.  表格多项查询

DataSource=DB.Select().Form(TableA).Where(TableA.ColName)
        .IsEqualTo("...").ExecuteDataSet();


DataSet user=DB.Select().From(TableA).Where(TableA.ColName)
         .IsEqualTo("...").ExecuteDataSet();
String str=user.Tables[0].Rows[0][“…”].ToString();

///////////////////////////////////////////
ViCaseSession.Query()
  .WHERE(ViCaseSession.Columns.Keywords, SubSonic.Comparison.Like,"%" + keywords + "%")
  .setTop(“1”). ExecuteDataSet();

  b.  单项详细查询

T t=new T(T.CName,”…”);

//不能用在视图上
T t=DB.Select(T).Where(T.CName).IsEqualTo(…).ExecuteSingle<T>();

//查询视图
IDataReader type_info = DB.Select(TbDetectionOperation.Columns.DetectionTypeId)
.From(Tables.TbDetectionOperation)
.Where(TbDetectionOperation.Columns.DetectionOperationId)
     .IsEqualTo(operation_id).ExecuteReader();
if (!type_info.Read())
{
  return string.Empty;
}
int type_id = (int)type_info["detection_type_id"];

 c.  分页查询

SubSonic.SqlQuery sql_query = DB.Select().From(Views.ViLugDownResult)
  .Where(ViLugDownResult.Columns.DetectionOperationId)
  .Like("%" + detection_operation_id + "%")
  .OrderAsc(ViLugDownResult.Columns.DetectionOperationId);
//分页设置

AspNetPager1.RecordCount = sql_query.GetRecordCount();
DataSet temp_dataset = sql_query.Paged(pageIndex, pageSize).ExecuteDataSet();

////////////////////////////////////////////////////////////////
query = ViCaseSession.Query()
  .WHERE(ViCaseSession.Columns.Keywords, SubSonic.Comparison.Like, "%" + keywords + "%")
  .AND(ViCaseSession.Columns.CaseName, SubSonic.Comparison.Like, "%" + keywords + "%")
  .BETWEEN_AND(ViCaseSession.Columns.StartOn, StartTime, StopTime)
  .BETWEEN_AND(ViCaseSession.Columns.EndOn, StartTime, StopTime)
  .AND(ViCaseSession.Columns.SessionStatus, 1);
//分页设置

AspNetPager1.RecordCount = query.GetRecordCount();
query.PageIndex = AspNetPager1.CurrentPageIndex;
query.PageSize = AspNetPager1.PageSize;
DataSource = query.ExecuteDataSet();

2.   创建新的数据

T t=new T();
t.Save();

3.   删除

DB.Delete().From().Where()

T.Delete(id);

 

posted on 2010-03-18 21:36  枫中稻草  阅读(647)  评论(1编辑  收藏  举报