Is there any way that I can access my SQL views in SubSonic 3.0? The code generation seems to skip views altogether
When SQL Server processes a SELECT from a view, it evaluates the code in the view BEFORE it deals with the WHERE clause or any join in the outer query. With more tables joined, it will be slow compared to a SELECT from base tables with the same results.
SQL Server views are helpful in many ways, for example in encapsulating complex multi-table query logic, allowing us to simplify client code. Views make queries faster to write, but they don't improve the underlying query performance.
Views are virtual tables that can be a great way to optimize your database experience. Not only are views good for defining a table without using extra storage, but they also accelerate data analysis and can provide your data extra security.
A VIEW in SQL Server is like a virtual table that contains data from one or multiple tables. It does not hold any data and does not exist physically in the database. Similar to a SQL table, the view name should be unique in a database. It contains a set of predefined SQL queries to fetch data from the database.
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_%'";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With