Checks whether nullability for a database column correspond to the nullability of the mapped entity member.
Namespace:
Huagati.DBMLTools.RuntimeAssembly: HuagatiDBMLToolsRTE (in HuagatiDBMLToolsRTE.dll) Version: 1.66.3362.23798
Syntax
C# |
---|
public static bool HasCorrectDBNullability( this MetaDataMember member, IDbConnection connection ) |
Visual Basic (Declaration) |
---|
<ExtensionAttribute> _ Public Shared Function HasCorrectDBNullability ( _ member As MetaDataMember, _ connection As IDbConnection _ ) As Boolean |
Visual C++ |
---|
[ExtensionAttribute] public: static bool HasCorrectDBNullability( MetaDataMember^ member, IDbConnection^ connection ) |
Parameters
- member
- Type: System.Data.Linq.Mapping..::.MetaDataMember
Linq-to-SQL MetaDataMember representing the column to check nullability for.
- connection
- Type: System.Data..::.IDbConnection
SQLConnection object for the database to compare to the model.
Return Value
True if nullability in the database is identical to nullability in the model for the member. False if nullability differs.
Examples
This example shows how to check whether a column corresponding to a Linq-to-SQL entity class member has the same nullability in the database as in the 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()) { //iterate through the members foreach (System.Data.Linq.Mapping.MetaDataMember member in table.RowType.DataMembers) { //only check non-association persistent members if (!member.IsAssociation && member.IsPersistent) { //check data type in the database if (member.HasCorrectDBNullability(dc.Connection)) { //the database column has the same nullability as the entity member in the model } else { //nullability don't match } } } } } }