Search Results for

    Show / Hide Table of Contents

    Class ColumnType

    A class holding the definition of a sql columnt type

    Inheritance
    System.Object
    ColumnType
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: LemonEdge.Utils.Database
    Assembly: Utils.dll
    Syntax
    [DataContract]
    public sealed class ColumnType

    Properties

    Collation

    Indicates the collation this column should use. Not needed by default the system will provide the database collation

    Declaration
    public string Collation { get; set; }
    Property Value
    Type Description
    System.String

    DefaultSQL

    SQL to give this column a default value when upgrading, or creating the column.

    For instance when changing a column from nullable to not nullable, this should have a default alue

    Declaration
    public string DefaultSQL { get; }
    Property Value
    Type Description
    System.String

    MaxTextSize

    If this type is a type of text column this holds the max size. Null is the equivelant of nvarchar(max)

    Declaration
    public short? MaxTextSize { get; }
    Property Value
    Type Description
    System.Nullable<System.Int16>

    Nullable

    Whether or not this column is nullable

    Declaration
    public bool Nullable { get; }
    Property Value
    Type Description
    System.Boolean

    Precision

    If this column is a decimal, this holds the precision

    Declaration
    public Precision Precision { get; }
    Property Value
    Type Description
    Precision

    Sparse

    Indicates if this column should be created as a sparse column

    Declaration
    public bool Sparse { get; set; }
    Property Value
    Type Description
    System.Boolean

    Type

    The sql type of this column

    Declaration
    public SQLType Type { get; }
    Property Value
    Type Description
    SQLType

    Methods

    Create(SQLType, Boolean, Nullable<Int16>, Nullable<Int16>, Nullable<Int16>, String, String)

    Creates a new column type with settings for all sql types

    Declaration
    public static ColumnType Create(SQLType type, bool nullable, short? length, short? precision, short? scale, string collation = "", string defaultSQL = "")
    Parameters
    Type Name Description
    SQLType type

    The sql type of the column to create

    System.Boolean nullable

    If the type should be nullable or not

    System.Nullable<System.Int16> length

    The default length for this column type if it is a text or similar type. If null then it would generate nvarchar(max) or similar

    System.Nullable<System.Int16> precision

    The number of total digits if this is a decimal type

    System.Nullable<System.Int16> scale

    The number of decimal places if this is a decimal type

    System.String collation

    The collation to use for this column if it is a text type

    System.String defaultSQL

    Any default sql for creating this column

    Returns
    Type Description
    ColumnType

    A new column type with settings for all sql types

    Create(SQLType, Boolean, String)

    Creates a new ColumnType without any text max settings, or decimal precision settings

    Declaration
    public static ColumnType Create(SQLType type, bool nullable, string defaultSQL = "")
    Parameters
    Type Name Description
    SQLType type

    The sql type of this column

    System.Boolean nullable

    If the type should be nullable or not

    System.String defaultSQL

    Any default sql for creating this column

    Returns
    Type Description
    ColumnType

    A new ColumnType without any text max settings, or decimal precision settings

    Create(Type, Boolean, String)

    Creates a new ColumnType using the default equivelant for the specified .Net Core type

    Declaration
    public static ColumnType Create(Type type, bool nullable, string defaultSQL)
    Parameters
    Type Name Description
    System.Type type

    The .Net Core type to create the equivelant default sql type for

    System.Boolean nullable

    If the type should be nullable or not

    System.String defaultSQL

    Any default sql for creating this column

    Returns
    Type Description
    ColumnType

    A new ColumnType using the default equivelant for the specified .Net Core type

    CreateWithLength(SQLType, Nullable<Int16>, Boolean, String, String)

    Creates a new ColumnType with settings for a string type of column

    Declaration
    public static ColumnType CreateWithLength(SQLType type, short? length, bool nullable, string collation = "", string defaultSQL = "")
    Parameters
    Type Name Description
    SQLType type

    The sql type of this column (should be nvarchar, text, varchar, or the like)

    System.Nullable<System.Int16> length

    The default length for this column type. If null then it would generate nvarchar(max)

    System.Boolean nullable

    If the type should be nullable or not

    System.String collation

    The collation to use for this column

    System.String defaultSQL

    Any default sql for creating this column

    Returns
    Type Description
    ColumnType

    A new ColumnType with settings for a string type of column

    CreateWithPrecision(SQLType, Precision, Boolean, String)

    Creates a new ColumnType with settings for decimal precision

    Declaration
    public static ColumnType CreateWithPrecision(SQLType type, Precision precision, bool nullable, string defaultSQL = "")
    Parameters
    Type Name Description
    SQLType type

    The sql type of this column (should be decimal or the like)

    Precision precision

    The precision for this decimal column type

    System.Boolean nullable

    If the type should be nullable or not

    System.String defaultSQL

    Any default sql for creating this column

    Returns
    Type Description
    ColumnType

    A new ColumnType with settings for decimal precision

    EquivelantDotNetType(Boolean)

    Returns the equivelant .Net Core type for this column

    Declaration
    public Type EquivelantDotNetType(bool includeNullable)
    Parameters
    Type Name Description
    System.Boolean includeNullable

    Indicates if the type returned should include if this column is nullable or not

    Returns
    Type Description
    System.Type

    The equivelant .Net Core type for this column

    FromType(Type)

    Creates a default equivelant ColumnType for the specified .Net Core type. For instance would return NVarchar(max) for typeof(string)

    Declaration
    public static ColumnType FromType(Type type)
    Parameters
    Type Name Description
    System.Type type

    The .Net Core type to return an equivelant default ColumnType for

    Returns
    Type Description
    ColumnType

    A default equivelant ColumnType for the specified .Net Core type. For instance would return NVarchar(max) for typeof(string)

    ToString()

    Returns the sql equivelant of this column, excluding nullable and collation info - so just the equivelant of the type like varchar(max)

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    The sql equivelant of this column, excluding nullable and collation info - so just the equivelant of the type like varchar(max)

    Overrides
    System.Object.ToString()

    ToString(Boolean, Boolean, String)

    Returns the sql equivelant of this column including attributes required for creating the column such as nullable and collation like varchar(max) collate xxx null

    Declaration
    public string ToString(bool includeNullable, bool includeCollation, string collationOverride = "")
    Parameters
    Type Name Description
    System.Boolean includeNullable
    System.Boolean includeCollation
    System.String collationOverride
    Returns
    Type Description
    System.String

    The sql equivelant of this column including attributes required for creating the column such as nullable and collation like varchar(max) collate xxx null

    Extension Methods

    MiscExtensions.SetIfNotEqual<T, P>(T, Expression<Func<T, P>>, P)
    ReflectionExtensions.ClearEventInvocations(Object, String)
    StringExtensions.ToCSVFormatString(Object, Type)
    SQLExtensions.ToSQLValue(Object, Boolean)
    In This Article
    Back to top © LemonTree Software Ltd. All rights reserved.