List of Views in a Database?

Posts   
 
    
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 03-Aug-2009 18:04:53   

Is there a way using an connected Adapter to get a list of the Views in a database from a specific schema?

We use the LLBL system as our data access layer.

Here's the SQL I use (Is there a better way using the internal LLBL tools?)


SELECT table_name AS object_name,
table_schema AS schema_name,
table_type AS object_type
FROM INFORMATION_SCHEMA.TABLES
WHERE table_type = 'VIEW'
and table_schema='rpt'

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Aug-2009 04:53:24   

H Ian,

I would do this:

  1. As the persistence info is accessible from the DataAccessAdapter. Create a partial class on the DBSpecific project and put this on it:
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace AW.DatabaseSpecific
{
    public partial class DataAccessAdapter
    {
        public string GetTypedViewSourceName(string tpvName)
        {           
            IFieldPersistenceInfo fieldInfo = GetFieldPersistenceInfos(tpvName)[0];
            return fieldInfo.SourceObjectName;
        }
    }
}
  1. At your project, do this:
List<string> tpvSourceNames = new List<string>();

using (DataAccessAdapter adapter = new DataAccessAdapter())
{
    foreach (string tpv in Enum.GetNames(typeof(TypedViewType)))
    {
        tpvSourceNames.Add(adapter.GetTypedViewSourceName(tpv));                    
    }
}

This will return the list of view's names that you added to your project (no all views on DB).

David Elizondo | LLBLGen Support Team