SubSonic Collection Top 1

Is there a way in the following code snippet to get only the first record?

Dal.TreeHtmlExportsCollection treeHtmlExportsCollection = new Dal.TreeHtmlExportsCollection().Where(Dal.TreeHtmlExports.Columns.TreeId, treeId). OrderByDesc(Dal.TreeHtmlExports.Columns.DateCreated).Load(); 
+6
collections subsonic
source share
1 answer

You can do this using the Query tool, for example: (SubSonic 2.1 required)

 var query = new Select() .Top("1") .From(TreeHtmlExports.Schema) .Where(TreeHtmlExports.Columns.TreeId).IsEqualTo(treeId) .OrderDesc(TreeHtmlExports.Columns.DateCreated); treeHtmlExportCollection = query.ExecuteAsCollection<TreeHtmlExportsCollection>(); 

Hope this helps!

+9
source share

All Articles