Sql=sqlselect+sqlfrom+sqlwhere+sqlorder
String sql = string. Empty;
String sqlselect = "Select CC." CLASSID,CC. CLASSNAME,CP. Coursename,pp. Title,pp. Releasetime,pp. Ispublic,pp.id as preparationid,cu.id as unitid,cp.id as packid,pp. Examid,pp. Ispractice,pp. Examid ";//Query column
Data sources
String sqlfrom = @ "from Yk_preparation pp--Lesson preparation
Join Yk_courseunit cu on pp. Coureunitid=cu.id--Course Modules
Join Yk_coursepack CP on CU. Coursepackid=cp.id--Course Package
Left joins Yk_courseclass cc on CC. COURSEPACKID=CP. Id ";
StringBuilder sqlwhere = new StringBuilder ();//Query condition
String Sqlorder = String. empty;//sort
String SqlCount = String. empty;//total number of records queried
Sqlwhere.append ("where pp. ' Status ' = 0 and cu. ' Status ' = 0");
Sqlwhere.append ("and CP. Teacherid = @0 ");//Current teacher
Sqlwhere.append ("and CP. term = @8 ");//Current Semester
Course Name
if (coursepackid>0)
Sqlwhere.append ("and cp.id [email protected]");
Course Modules
if (unitid>0)
Sqlwhere.append ("and cu.id [email protected]");
Whether to share (-1: All, 0: not shared, 1: Shared)
if (IsPublic >=0)
Sqlwhere.append ("and pp. IsPublic = @3 ");
Release date
Sqlwhere.append ("and pp. Releasetime between @4 and @5 ");
Sqlorder= "ORDER by pp. Releasetime DESC ";
sql = sqlselect + sqlfrom + sqlwhere.tostring () + Sqlorder + "Limit @6,@7";
SqlCount = @ "SELECT count (pp.id)" +sqlfrom+sqlwhere.tostring ();
int pagestart = (pageIndex-1) * pageSize;
list<preparationmodel> list = _content. findpage<preparationmodel> (SQL, SqlCount, PageIndex, pageSize, out TotalCount, Teacherid, Coursepackid, Unitid, IsPublic, Publishdatestart, Publishdateend, Pagestart, Pagesize,termid);
return list;
List condition Paging query