Wiki · Bugs · Lists · Source

Neo quickstart

  1. Download and install the Neo MSI installer.
  2. Create a new solution in VisualStudio.NET 2003 and add Neo.dll as reference to the project. Note that VisualStudio 2005 (a.k.a. Whidbey) is not supported yet.
  3. Write a model file for your entities and the relationships between them. Have a look at the following sample model for some inspiration.

    <database name="movies" package="Movies.Model" defaultIdMethod="native">
      <table name="person">
        <column name="person_id" primaryKey="true" hidden="true" type="INTEGER" />
        <column name="name" required="true" type="VARCHAR" size="500" />
      <table name="movie">
        <column name="movie_id" primaryKey="true" hidden="true" type="INTEGER" />
        <column name="title" required="true" type="VARCHAR" size="500" />
        <column name="director_id" required="true" hidden="true" type="INTEGER" />
        <foreign-key foreignTable="persons" name="Director"> 
          <reference local="director_id" foreign="person_id"/> 

  4. Add the Neo code generator to the model file as described in the VsToolGuide available on the docs page. Now, whenever you make changes to the model, Neo will update the underlying source code.
  5. Write your application code. The lines below retrieve a movie from the database, then create a new director and assign it to the movie and finally save all changes back in one transaction.

        IDataStore store = new SqlDataStore(" ... connection string ... ");
        ObjectContext context = new ObjectContext(store);
        MovieFactory factory = new MovieFactory(context);
        Movie starwars = factory.Find("title = 'Star Wars');
        Person george = new PersonFactory(context).CreateObject();
        george.Name = "George Lucas";
        starwars.Director = george;

As easy as that! Now please check the documentation.