[ENG] CSLA .NET basic example with Windows Forms (part I)


Hi everybody, back here again to talk about CSLA.NET, in the previous post I mentioned how this Framework and have decided that the best is to learn with a practical example.

To start, I want to make a small application that is made up of only 4 tables and allow maintenance, creating very simple validation rules and a transaction for you to see how easy that will result if they develop an application with Windows Forms.

The technologies that I will use in this project are:

As you can see you don’t need much to advance, they should only have Visual Studio 2013 Community Edition or higher.

Let’s start creating 3 projects:

Snap1

Then in the DemoCSLA.Datos project, we add an Entity Data Model:

Snap2

Choose the option ‘Empty EF Designer Model’

Snap3

Then we create an entity in the following manner:

Snap4

We then create a scalar property:

Snap5

By default, all properties scalars are created as ‘String’, to change its type only simply select a property and press the F4 key:

Snap6

The types of data for the properties are:

Snap18

The model we should be as well:

Snap8

Now we create the relationship between the tables by selecting the ‘Association’ object in the Toolbox.

Snap7

Once selected just drag from the entity of origin to the destination entity relationship that we want to create, the model should look like the following:

Entity Data Model DemoCSLA

We are now heading towards Server Explorer (Ctrl + W + L) and create a local database:

Snap11

We give the name DemoCSLADb:

Snap12

We make sure that you have created the database correctly:

Snap13

Now in an empty part of the model right click and select the option ‘ Generate Database from Model’

Snap10

As we have previously created the database, by default we have selected such a connection.

Snap14

Pressing the next button, you should see the Script that we have generated, we indicate the resulting Script name and can then adapt it to our needs:

Snap15

Since created as String fields are defined as NVARCHAR (MAX) I have replaced the word MAX for number 200, so I give a fixed string fields size:

Snap16

Finally execute the modified Script and select the connection:

Snap17

Here we have created our practical example data access layer, stay tuned to the next part to create the business objects of CSLA. NET.

They can go and see the progress of the project in my personal repository from GitHub.

ver-github1

See you soon!

Un comentario sobre “[ENG] CSLA .NET basic example with Windows Forms (part I)

Deja un comentario

Este sitio utiliza Akismet para reducir el spam. Conoce cómo se procesan los datos de tus comentarios.