public void Run(MSSQLColumn <TTableContent, TColumnContent> column, SimplePropertyEntityInfo obj) { if (string.IsNullOrEmpty(column.Default)) { obj.DefaultValue = DbDefaultToCSharpConverter.ConvertDefault(column.TypeDescription.BaseType, column.Default); //TODO: Log failed default convertation } }
public void Run(MSSQLColumn <TTableContent, TColumnContent> column, SimplePropertyEntityInfo obj) { obj.IsUnicode = column.TypeDescription.IsUnicode; obj.IsRowGuid = column.IsRowGuid; #region Length if (column.TypeDescription.HasLength) { obj.Length = column.Length; obj.IsFixedLength = column.TypeDescription.IsFixedLength; } #endregion #region DatabaseGeneratedOption switch (column.ColumnType) { case ColumnTypes.Identity: obj.DatabaseGeneratedOption = DatabaseGeneratedOption.Identity; break; case ColumnTypes.IsComputed: obj.DatabaseGeneratedOption = DatabaseGeneratedOption.Computed; break; } #endregion }
private void PrepareEntityPropertyName(MSSQLColumn<TableContent, ColumnContent> obj) { obj.Content.CodeName = TransformName(obj.Name).ToPascalCase(); obj.Content.CodeNamePlural = Pluralize(obj.Content.CodeName); }
private static KeyValuePair <Tuple <int, int>, MSSQLColumn <TTableContent, TColumnContent> > ExtractColumn(DataRow row) { var key = new Tuple <int, int>((int)row["parent_id"], (int)row["id"]); var column = new MSSQLColumn <TTableContent, TColumnContent>(); column.Name = row["name"].ToString(); column.ColumnType = (ColumnTypes)Enum.ToObject(typeof(ColumnTypes), row["type"]); column.IsRequired = !(bool)row["is_nullable"]; column.Default = row["default"].ToString(); column.IsRowGuid = (bool)row["is_rowguidcol"]; if (column.ColumnType == ColumnTypes.IsComputed) { column.ComputedBody = row["computed_body"].ToString(); } var typeId = (int)row["type_id"]; var systemTypeId = (NativeTypes)Enum.ToObject(typeof(NativeTypes), row["system_type_id"]); //NOTE: System types from 1 to 255 column.NativeType = typeId < 256 ? (NativeTypes)Enum.ToObject(typeof(NativeTypes), typeId) : systemTypeId; var desc = MSSQLTypeDescriptions.Dictionary.GetDesc(column.NativeType); if (desc.IsDerived) { desc = MSSQLTypeDescriptions.Dictionary.GetDesc(systemTypeId); } #region Skip unsuported types switch (desc.BaseType) { case NativeTypes.Clr: case NativeTypes.Table: return(default(KeyValuePair <Tuple <int, int>, MSSQLColumn <TTableContent, TColumnContent> >)); } #endregion #region Length if (desc.HasLength) { var length = (short)row["length"]; if (desc.BaseType == NativeTypes.NVarchar || desc.BaseType == NativeTypes.NChar) { length /= 2; } column.Length = length; } #endregion #region Precision if (desc.HasPrecision) { column.Precision = (byte)row["precision"]; } #endregion #region Scale if (desc.HasScale) { column.Scale = (byte)row["scale"]; } #endregion #region Collation if (desc.HasCollation) { column.Collation = row["collation"].ToString(); } #endregion return(new KeyValuePair <Tuple <int, int>, MSSQLColumn <TTableContent, TColumnContent> >(key, column)); }
private void PrepareEntityPropertyName(MSSQLColumn <TableContent, ColumnContent> obj) { obj.Content.CodeName = TransformName(obj.Name).ToPascalCase(); obj.Content.CodeNamePlural = Pluralize(obj.Content.CodeName); }