Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Views in SubSonic 3.0

Is there any way that I can access my SQL views in SubSonic 3.0? The code generation seems to skip views altogether

like image 853
Karl Avatar asked Jul 03 '09 08:07

Karl


People also ask

Why are SQL views slow?

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.

Do SQL views affect performance?

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.

Is it good to use views in SQL?

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.

Does SQL Server support views?

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.


1 Answers

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_%'";
like image 88
freddoo Avatar answered Oct 25 '22 03:10

freddoo