private string GetCSDataType(string strTypeName) { PublicEnums.DataTypes objDataType = 0; objDataType = PublicEnums.GetTypeByName((strTypeName)); switch (objDataType) { case PublicEnums.DataTypes.BigInt: case PublicEnums.DataTypes.Numeric: return("Int64"); case PublicEnums.DataTypes.SmallInt: case PublicEnums.DataTypes.Int: return("int"); case PublicEnums.DataTypes.TinyInt: return("Int16"); case PublicEnums.DataTypes.Decimal: case PublicEnums.DataTypes.Float: case PublicEnums.DataTypes.Money: case PublicEnums.DataTypes.Real: case PublicEnums.DataTypes.SmallMoney: return("float"); case PublicEnums.DataTypes.Char: case PublicEnums.DataTypes.NChar: case PublicEnums.DataTypes.NVarchar: case PublicEnums.DataTypes.Varchar: case PublicEnums.DataTypes.Text: case PublicEnums.DataTypes.NText: case PublicEnums.DataTypes.XML: return("string"); case PublicEnums.DataTypes.Bit: return("bool"); case PublicEnums.DataTypes.Date: case PublicEnums.DataTypes.DateTime: case PublicEnums.DataTypes.DateTime2: case PublicEnums.DataTypes.DateTimeOffset: case PublicEnums.DataTypes.SmallDateTime: case PublicEnums.DataTypes.Time: case PublicEnums.DataTypes.TimeStamp: return("DateTime"); case PublicEnums.DataTypes.Geography: case PublicEnums.DataTypes.Geometry: case PublicEnums.DataTypes.HierarchyID: case PublicEnums.DataTypes.Image: case PublicEnums.DataTypes.SQL_Variant: case PublicEnums.DataTypes.Binary: case PublicEnums.DataTypes.Varbinary: case PublicEnums.DataTypes.UniqueIdentifier: return("object"); }//end switch return(""); }
private string GenerateAttachedParameters() { string attached_parameters = string.Empty; foreach (Column column in table.Columns) { string variable_name = PublicEnums.GetPrefix(column.TypeName) + column.ColumnName; attached_parameters += "com" + column.TableName + ".Parameters.AddWithValue" + "(\"" + column.ColumnName + "\", " + variable_name + ");" + Environment.NewLine; } return(attached_parameters); }
private string GeneratePrivateVariables() { string variable_list = string.Empty;; foreach (Column column in table.Columns) { string variable_name = string.Empty; variable_name = GetCSDataType(column.TypeName); variable_name += " " + PublicEnums.GetPrefix(column.TypeName); variable_name += column.ColumnName; variable_name += ";"; variable_list += variable_name + Environment.NewLine; } return(variable_list); }
private string GeneratePublicProperties() { string property_list = string.Empty; string property_template = File.ReadAllText(cs_template_path + "Property.tem"); foreach (Column column in table.Columns) { string public_property = property_template; string data_type = GetCSDataType(column.TypeName); string property_name = column.ColumnName; string variable_name = PublicEnums.GetPrefix(column.TypeName) + column.ColumnName; public_property = public_property.Replace("__DataType", data_type); public_property = public_property.Replace("__PropertyName", property_name); public_property = public_property.Replace("__VariableName", variable_name); public_property += Environment.NewLine; property_list += public_property; } return(property_list); }