Created
December 19, 2014 05:18
-
-
Save androidcn/c333afd70134862edb0d to your computer and use it in GitHub Desktop.
泛型
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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