分類:public class Category{public int id{get;set;}public string categoryname{get;set;}}內容:public class Content{public int id{get;set;}public string title{get;set;}public string content{get;set;}public int categoryid{get;set;}public Category currentcategory{get;set;}}內容表中的categoryid是外鍵,指向Category的id現在的需求是在獲取內容列表時,同時也需要獲取內容所屬的分類,并賦值給currentcategory.現在的 SQL是:select * from (select *,Row_Number() over(order by id desc) as rowNumber from tb_Content where categoryid=@categoryid)t where t.rowNumber>= @start and t.rowNumber<=@endList<Content> list= conn.Query<Content>(sql,new{categoryid=categoryid,start=start,end=end}).ToList();這樣獲取不到currentcategory。
- 1 回答
- 0 關注
- 482 瀏覽
添加回答
舉報
0/150
提交
取消