Checks if a table exist in the database.
Namespace:
Huagati.DBMLTools.RuntimeAssembly: HuagatiDBMLToolsRTE (in HuagatiDBMLToolsRTE.dll) Version: 1.66.3362.23798
Syntax
| C# |
|---|
public static bool ExistsInDB( this MetaTable table, IDbConnection connection ) |
| Visual Basic (Declaration) |
|---|
<ExtensionAttribute> _ Public Shared Function ExistsInDB ( _ table As MetaTable, _ connection As IDbConnection _ ) As Boolean |
| Visual C++ |
|---|
[ExtensionAttribute] public: static bool ExistsInDB( MetaTable^ table, IDbConnection^ connection ) |
Parameters
- table
- Type: System.Data.Linq.Mapping..::.MetaTable
Linq-to-SQL MetaTable object for the table to locate.
- connection
- Type: System.Data..::.IDbConnection
Database connection.
Return Value
True if the table exist, false if it is missing.
Examples
This example shows how to check whether a table exist in the database or not:
CopyC#
using Huagati.DBMLTools.Runtime; public class MappingSample { public void Test() { SomeDataContext dc = new SomeDataContext(); //iterate through the collection of tables defined in the datacontext foreach (System.Data.Linq.Mapping.MetaTable table in dc.Mapping.GetTables()) { if (table.ExistsInDB(dc.Connection)) { //table exists in the database } else { //table does not exist in the database } } } }