Linq2SQL has the great Log property to see what the actual SQL statements that it is generating. Does SubSonic 2.2 have something similar to this?
Asked
Active
Viewed 350 times
3 Answers
1
http://www.e-webdevelopers.com/268/view-the-sql-generated-by-subsonic/
SqlQuery sq = new Select()
.From(Item.Schema)
.InnerJoin(ItemStatus.IstIDColumn, Item.ItmStatusColumn)
.InnerJoin(ItemCategory.ItcItemIDColumn, Item.ItmIDColumn)
.WhereExpression("ItmIsEnabled").IsEqualTo(true)
.AndExpression("ItmName").Like("%" + findThis + "%")
.Or(Item.ItmShortDescriptionColumn).Like("%" + findThis + "%")
.Or(Item.ItmItemCodeColumn).Like("%" + findThis + "%")
.Or(Item.ItmLongDescriptionColumn).Like("%" + findThis + "%")
.Paged(pageIndex, PageSize)
.OrderAsc("itmName");
Response.Write(sq.ToString());
Not tested as I'm not infront of my dev box. Hope that helps.

LiamB
- 18,243
- 19
- 75
- 116
-
1The problem with this means finding every query and adding a line next to it to do the logging. What I was hoping for was a universal system I can subscribe to similar to how Linq2SQL has. – Robert MacLean Nov 11 '09 at 09:33
-
I dont think Subsonci supports that at present. Maybe add it in ;) – LiamB Nov 11 '09 at 09:45
0
SubSonic 2.2 ActiveRecord has some events you can override, like AfterValidate() and BeforeCommit(). You could use one of those to log the Sql, but you would have to modify your templates so that code ended up in all your classes.
Or just hit up SubSonic\DataProviders\DataService.cs in your local SubSonic source and see if it will work to add your logging events to all of the .Execute* methods.

Dave Neeley
- 3,526
- 1
- 24
- 42