Get through all tables of a database
-
I want to get through all tables of a database with a select how can I do it?
-
I want to get through all tables of a database with a select how can I do it?
If you're using LINQ, it depends which database you're targetting. If you were using the old ODBC ways of accessing databases, there was a set of metadata queries that you could perform that were nice and generic - however, as you are using L2S, the method depends on the database provider. For instance, in SQL Server, you could use
SELECT [FieldList goes here] FROM information_schema.Tables
-
If you're using LINQ, it depends which database you're targetting. If you were using the old ODBC ways of accessing databases, there was a set of metadata queries that you could perform that were nice and generic - however, as you are using L2S, the method depends on the database provider. For instance, in SQL Server, you could use
SELECT [FieldList goes here] FROM information_schema.Tables
I'm using Linq (Entity Framework)... what can I do?
-
I'm using Linq (Entity Framework)... what can I do?
Write a stored procedure that gets the values and hook up to that.
-
Write a stored procedure that gets the values and hook up to that.
I don't have the rights to write a stored procedure... don't ask why ... i'm freaking out with this database...
-
I don't have the rights to write a stored procedure... don't ask why ... i'm freaking out with this database...
You can use the
SqlQuery
method[^] on theDatabase
[^] to execute a raw query:IEnumerable<string> tables = context.Database.SqlQuery<string>("SELECT QUOTENAME(s.name) + '.' + QUOTENAME(t.name) As TableName FROM sys.tables As t INNER JOIN sys.schemas As s ON s.schema_id = t.schema_id ORDER BY s.name, t.name");
Entity Framework Raw SQL Queries[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer