Returns a SQL-DDL statement for dropping the primary key (and any FKs referring to it) on a table
Namespace:
Huagati.DBMLTools.RuntimeAssembly: HuagatiDBMLToolsRTE (in HuagatiDBMLToolsRTE.dll) Version: 1.66.3362.23798
Syntax
C# |
---|
public static string DropPKStatement( this MetaTable table ) |
Visual Basic (Declaration) |
---|
<ExtensionAttribute> _ Public Shared Function DropPKStatement ( _ table As MetaTable _ ) As String |
Visual C++ |
---|
[ExtensionAttribute] public: static String^ DropPKStatement( MetaTable^ table ) |
Parameters
- table
- Type: System.Data.Linq.Mapping..::.MetaTable
Linq-to-SQL MetaTable object for the table to generate the SQL-DDL 'drop table' statement for.
Return Value
A string containing SQL-DDL for dropping a primary key and any foreign keys referring to it.
Examples
This example shows how to generate SQL-DDL for dropping the primary keys for each table in a Linq-to-SQL datacontext, and any referring foreign key constraints.
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()) { string dropPKandRelatedFKs = table.DropPKStatement(); } } }