Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 1.56 KB

use_your_data_access_layer.md

File metadata and controls

60 lines (43 loc) · 1.56 KB

Use your Data Access Layer

Create your application

Add a console application project into your solution and add a reference to your generated C# project.

Add a loop to display the list of your products.

using System;
using OrderProcess.Marketing;

namespace OrderProcess.Application
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (Product product in ProductCollection.LoadAll())
            {
                Console.WriteLine(product.Name);
            }
            Console.ReadKey();
        }
    }
}

Then configure the App.config file. Declare a new configuration section with a section name matching your default namespace and set up your connection string.

<configuration>
  <configSections>
    <section name="MyDefaultNamespace"
             type="CodeFluent.Runtime.CodeFluentConfigurationSectionHandler, CodeFluent.Runtime" />
  </configSections>
  <MyDefaultNamespace connectionString="database=[MyDatabaseName];server=[ServerName];Trusted_Connection=true" />
</configuration>

Add instances

Now let's add some data to our model. Select the Product entity and open the Instances Grid windows from the ribbon.

Fill the grid with all the products you need to initialize your database.

Build your model and your database is now filled with your initial data.

Run the application

Now run the application. It should display our three products.