Public Function ExportSchema() As List(Of SchemaClass)
Dim instance As NinjaDbPro Dim value As List(Of SchemaClass) value = instance.ExportSchema()
public List<SchemaClass> ExportSchema()
public: List<SchemaClass^>^ ExportSchema();
Public Function ExportSchema() As List(Of SchemaClass)
Dim instance As NinjaDbPro Dim value As List(Of SchemaClass) value = instance.ExportSchema()
public List<SchemaClass> ExportSchema()
public: List<SchemaClass^>^ ExportSchema();
NinjaDbPro db = new NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName"); db.Storage = new FileDatabase(); //Licensed Mode //db.UserName = "John Smith 101224"; //db.LicenseKey = "aousdf832jasf=="; Order order = new Order(); order.Buyer = new Person(); order.Buyer.Name = "John Doe"; order.Buyer.DateCreated = DateTime.Now; order.OrderDetails = new List<OrderDetail>(); OrderDetail detail1 = new OrderDetail(); detail1.Item = new Product(); detail1.Item.Name = "Wizard"; detail1.Item.Cost = 29.98M; detail1.Quantity = 2; detail1.Order = order; order.OrderDetails.Add(detail1); OrderDetail detail2 = new OrderDetail(); detail2.Item = new Product(); detail2.Item.Name = ".NET Caching Library"; detail2.Item.Cost = 199.95M; detail2.Quantity = 1; detail2.Order = order; order.OrderDetails.Add(detail2); db.OpenDatabase(); //Everything will be saved to the database in seperate tables in an implicit transaction //You must have the relationships set up as attributes. See setting up relationships. //This is wrapped in an implicit transaction, if any record fails it will all roll back db.Save(order); db.CloseDatabase(); //We can export the schema with the database closed List<SchemaClass> schemaClasses = db.ExportSchema(); //Write each class to a file foreach (var schemaClass in schemaClasses) { string className = schemaClass.Name + ".cs"; File.WriteAllText(className,schemaClass.Definition); }
Dim db As New NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName") db.Storage = New FileDatabase() 'Licensed Mode 'db.UserName = "John Smith 101224"; 'db.LicenseKey = "aousdf832jasf=="; Dim order As New Order() order.Buyer = New Person() order.Buyer.Name = "John Doe" order.Buyer.DateCreated = Date.Now order.OrderDetails = New List(Of OrderDetail)() Dim detail1 As New OrderDetail() detail1.Item = New Product() detail1.Item.Name = "Wizard" detail1.Item.Cost = 29.98D detail1.Quantity = 2 detail1.Order = order order.OrderDetails.Add(detail1) Dim detail2 As New OrderDetail() detail2.Item = New Product() detail2.Item.Name = ".NET Caching Library" detail2.Item.Cost = 199.95D detail2.Quantity = 1 detail2.Order = order order.OrderDetails.Add(detail2) db.OpenDatabase() 'Everything will be saved to the database in seperate tables in an implicit transaction 'You must have the relationships set up as attributes. See setting up relationships. 'This is wrapped in an implicit transaction, if any record fails it will all roll back db.Save(order) db.CloseDatabase() 'We can export the schema with the database closed Dim schemaClasses As List(Of SchemaClass) = db.ExportSchema() 'Write each class to a file For Each schemaClass In schemaClasses Dim className As String = schemaClass.Name & ".cs" File.WriteAllText(className,schemaClass.Definition) Next schemaClass
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2