public void SqlConverter_Convert_UseQuotesSyntax_ReturnClassRepresentationOfTable() { string createScript = $"CREATE TABLE \"Categories\" (" + "\"CategoryID\" \"int\" IDENTITY(1, 1) NOT NULL," + "\"CategoryName\" nvarchar(15) NOT NULL," + "\"Description\" \"ntext\" NULL ," + "\"Picture\" \"image\" NULL )"; var tablecs = _sqlConverter.Convert(createScript); Assert.IsNotNull(tablecs); Assert.AreEqual(_generatedDomainName, tablecs.Namespace); Assert.AreEqual("Category", tablecs.TableDefinition.TableName); Assert.AreEqual(4, tablecs.TableDefinition.Fields.Count()); Assert.AreEqual("CategoryName", tablecs.TableDefinition.Fields.ElementAt(1).FieldName); Assert.AreEqual("string", tablecs.TableDefinition.Fields.ElementAt(1).FieldType); }
static void Main(string[] args) { var converterConfigs = ConfigurationManager.GetSection("converterConfigs") as ConverterConfigurationSection; string outPath = converterConfigs.OuputFilesPath; IConverter <string, TableClassRepresentation> converter = new SqlConverter(converterConfigs.DomainNamespace, SQLTypes.MSSQLTypes); DirectoryInfo directory = new DirectoryInfo(converterConfigs.SqlFilesPath); if (!new DirectoryInfo(outPath).Exists) { Directory.CreateDirectory(outPath); } foreach (var sqlDefinition in directory.GetFiles()) { var cstable = converter.Convert(File.ReadAllText(sqlDefinition.FullName)); using (StreamWriter streamWriter = new StreamWriter(outPath + cstable.TableDefinition.TableName + ".cs")) streamWriter.Write(cstable); } }