Is there any way that I can access my SQL views in SubSonic 3.0? The code generation seems to skip views altogether
+1
A:
The SubSonic 3 templates don't generate code for views yet. You could add the functionality yourself quite easily though, have a look at the LoadTables and GetSPs methods in SQLServer.ttinclude to see how SubSonic builds lists of tables\stored procedures.
Adam
2009-07-03 10:16:44
+15
A:
To include views in your project
simply open SQLServer.ttinclude Find the query that load the tables ( search form 'const string TABLE_SQL') then change it to
const string TABLE_SQL=@"SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
union
select Table_catalog, table_schema, table_name, 'View' table_type
from information_schema.views";
if you are using it in an asp.net project you can exclude the aspnet table and views like so
const string TABLE_SQL=@"SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
and table_name not like '%aspnet_%'
union
select Table_catalog, table_schema, table_name, 'View' table_type
from information_schema.views
where table_name not like '%aspnet_%'";
freddoo
2009-07-08 12:30:57
+10, if I could, thx
DrG
2009-07-26 20:08:28
Only problem is then you have Save(),Delete(), etc methods on the view objects that don't really apply to Views
Jeremy Coenen
2009-08-20 14:25:19
I have not tried to save or delete a view, but sql wise it's possible to update a view. I guess the best solution would be to create a template for view and return read-only objects.
freddoo
2009-08-24 18:32:46
+1 you saved the day
TheVillageIdiot
2010-01-30 21:35:42