Introduction

This is a simple app using a persistent class. The app creates a persistent object, writes it into the database and reads it from the database. It uses SqlServerCe.

Building the Sample

Just unpack the solution and recompile. It should load the ndo.dll nuget package. Load the NDO VSIX extension to work with ndo.

Description

The sample uses the PersistenceManager class to make an object persistent.

NDO is a powerful object-relational mapping tool for .NET. NDO simplifies storing objects of your .NET classes in relational databases. Simply write business classes and mark them with the attribute [NDOPersistent]. Then recompile and NDO takes care for the persistency. NDO supports Linq queries to fetch your objects. NDO complies fully to the ECMA standard and the CLI, so your NDO-based applications run under mono as well as under Microsoft .NET and .NET Core.

 

C#
Skript bearbeiten|Remove
using NDO; 
using System; 
using System.Collections.Genericusing System.Linqusing System.Textusing System.Threading.Tasks; 
 
namespace SimpleNDOSample 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            BuildDatabase(); 
            ReadData(); 
        } 
 
        static void BuildDatabase() 
        { 
            PersistenceManager pm = new PersistenceManager(); 
            pm.BuildDatabase();  // This builds the database structure 
 
            Person person = new Person() { FirstName = "Mirko", LastName = "Matytschak" }; 
            pm.MakePersistent(person);  // Up to this point, person is a simple .NET object 
            pm.Save();  // writes the object to the database 
        } 
 
        private static void ReadData() 
        { 
            PersistenceManager pm = new PersistenceManager(); 
 
            foreach (var person in (from p in pm.Objects<Person>() where p.FirstName == "Mirko" select p).ResultTable) 
                Console.WriteLine(person.FirstName + " " + person.LastName); 
        } 
    } 
} 

More Information

To find more information, look at http://www.netdataobjects.de.

Introduction

This is a simple app using a persistent class. The app creates a persistent object, writes it into the database and reads it from the database. It uses SqlServerCe.

Building the Sample

Just unpack the solution and recompile. It should load the ndo.dll nuget package. Load the NDO VSIX extension to work with ndo.

Description

The sample uses the PersistenceManager class to make an object persistent.


 

 

C#
Skript bearbeiten|Remove
using NDO; 
using System; 
using System.Collections.Genericusing System.Linqusing System.Textusing System.Threading.Tasks; 
 
namespace SimpleNDOSample 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            BuildDatabase(); 
            ReadData(); 
        } 
 
        static void BuildDatabase() 
        { 
            PersistenceManager pm = new PersistenceManager(); 
            pm.BuildDatabase();  // This builds the database structure 
 
            Person person = new Person() { FirstName = "Mirko", LastName = "Matytschak" }; 
            pm.MakePersistent(person);  // Up to this point, person is a simple .NET object 
            pm.Save();  // writes the object to the database 
        } 
 
        private static void ReadData() 
        { 
            PersistenceManager pm = new PersistenceManager(); 
 
            foreach (var person in (from p in pm.Objects<Person>() where p.FirstName == "Mirko" select p).ResultTable) 
                Console.WriteLine(person.FirstName + " " + person.LastName); 
        } 
    } 
} 

Source Code Files

More Information

To find more information, look at http://www.netdataobjects.de.