Skip to content

Instantly share code, notes, and snippets.

@androidcn
Created December 19, 2014 05:18
Show Gist options
  • Save androidcn/c333afd70134862edb0d to your computer and use it in GitHub Desktop.
Save androidcn/c333afd70134862edb0d to your computer and use it in GitHub Desktop.
泛型
public Q getQuestion<Q>(int QuestionID,int ChapterID)where Q:IQuestion,new(){
if (QuestionID == 0) {
using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(docPath)) {
var questionS =(from b in conn.Table<Q> ()
where b.question_level==0 && b.chapter_id==ChapterID
select b
).Take (1);
List<Q> ListQuestionS=new List<Q>(questionS);
return ListQuestionS[0];
}
} else {
using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(docPath)) {
var questionS =new List<Q>(from b in conn.Table<Q> ()
where b.question_id==QuestionID && b.chapter_id==ChapterID
select b
);
return questionS[0];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment