Returns a SQL-DDL statement for adding a primary key to a table.
Namespace:
Huagati.DBMLTools.RuntimeAssembly: HuagatiDBMLToolsRTE (in HuagatiDBMLToolsRTE.dll) Version: 1.66.3362.23798
Syntax
C# |
---|
public static string CreatePKStatement( this MetaTable table ) |
Visual Basic (Declaration) |
---|
<ExtensionAttribute> _ Public Shared Function CreatePKStatement ( _ table As MetaTable _ ) As String |
Visual C++ |
---|
[ExtensionAttribute] public: static String^ CreatePKStatement( MetaTable^ table ) |
Parameters
- table
- Type: System.Data.Linq.Mapping..::.MetaTable
Linq-to-SQL MetaTable object for the table to generate the SQL-DDL 'alter table ... add primary key' statement for.
Return Value
A string containing SQL-DDL for dropping the table.
Examples
This example shows how to generate SQL-DDL statement for adding primary keys to all tables in a Linq-to-SQL model.
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 createPK = table.CreatePKStatement(); } } }