Tuesday, June 30, 2009

97 Things Every Software Architect Should Know

 

  I would like to add 3 more to make it 100.   Once i finish reading all 97 i will come to know what is missing then i will add those required points to  make it 100 ==Perfect .

image

http://97-things.near-time.net/wiki/97-things-every-software-architect-should-know-the-book

Nandri(Thanks)

SreenivasaRagavan.

VS.NET 2010 Modeling a Project.

In VS.NET 2010 Team Suite Beta 1 Edition we have new project type called Modeling Projects. This modeling projects help us to model or create  our Data , Activity , Use case, Sequence Diagram, Logical Class Diagram etc…

The above models are Represented as UML Models.  Let me show you how to create the Logical Class diagram using this Modeling Project .

Step 1: Create New Modeling Project.

image

Right Click and Add new Item then add Logical Class Diagram from the available modeling template.

image

Here i am going to add sample user class with few attributes and Operations. 

Now you can right click  on the UML design surface or drag and drop a Type from Toolbox .  let us right click and Add Class Type and Name that type as User.

image

Now right click on Class (User) Type and Add Attribute and send the Properties for that attributes like Type (string, bool ), Visibility (Private ,public) image

same way now we are going to add Operations and set  the Properties like  Return Type as shown below.

image

UML Representations of a User Class.

 image

I just exploring VS.NET 2010 Team Suite Beta 1. I will keep posting stay tuned

Nandri(Thanks)

SreenivasaRagavan

Sunday, June 21, 2009

Model First Development using VS.NET 2010 Beta 1 & Entity Framework

Until VS.NET 2010 Bea1 Released we have been creating our model from Existing Database. Now we are going to take the route  from Model First then Create our Persistence  Layer or Database.

Step1 :  First Create ASP.NET Web Application  ( you can use other .NET project as well).

image

Step 2: Now add ADO.NET Entity Data Model to the project we just created above.

image

Now the  Entity Data Model Wizard will gives two options in that now we are going to select Second option called Empty Model

(VS.NET 2008 SP1 this options was there but it was not working)

image

Now we can start creating our Entities and Define the Relations among them.

image

Now Right click on the  Design surface and start adding entity and properties and type. Here for the heck i am taking simple example School , Player, Game et..

I am going to create the 4 Entities namely   SCHOOL, PLAYER, GAME, STADIUM and Define the relations between them.

image image

 

image

Now we have Created our Entities ,their properties and relations. now time to generate  database for our model to map to. This is what  i like Microsoft  IDE and tools so simple to create and Develop. Now Right click on the model designer area and click “Generate Database Script From Model… as shown above.

Now you will asked to select   DB Server name.[ The standard database connection dialog we are all used to in Visual Studio when  Adding a connection]image

Now you need to cut the generated script and paste into SQL server Management Studio and execute it against your database.  The database itself will have been created, but in this beta version you still need to execute the scripts manually.  This will not be the case in the final version of VS.NET 2010.

Here is the Relational Model

image

Nandri(thanks)

SreenivasaRagavan

Monday, June 15, 2009

Monday, June 1, 2009

ADO.NET Data Service CTP V 1.5 new feature –$count [ Row Count]

In ADO.NET Data Service  CTP V1.5 we can query the  Entity records count before downloading the whole entity using  $count .

1) Create ASP.NET Web Application.

2 ) Add ADO.NET Data Service Template .

3) Now we need to define/Create our Data source which we need Surface via ADO.NET  Data Service .  Here i am going to use  Customer ,Order tables  from North wind DB as my  entity .

Now  Add  ADO.NET Entity Framework model template to the project and follow the  Wizard .

image

Now we need to add manually the following two References from  the directory where  ADO.NET Data service CTP V 1.5  installed . [ Note: Remove old Version 1.0  Reference System.Data.Services, System.Data.Services.Client before adding new version]

The above step is very important, otherwise you wont able to use $count operator .

image

using System;
usingSystem.Collections.Generic;
usingSystem.Data.Services;
usingSystem.Linq;
usingSystem.ServiceModel.Web;
usingSystem.Web;

namespaceNewDataService
{
    public classWebDataService1: DataService<NorthwindEntities>
    {
         public static voidInitializeService(IDataServiceConfiguration config)
        {
             config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
        }
    }
}

After paramterizing the DataService browse the .SVC 


image 


Now in Brower Address bar type the following rest URI.


http://localhost:51204/WebDataService1.svc/Orders/$count 


image 


The result of the above REST URL   tells Orders Entity has 830 Records.


 



Nandri(Thanks)



R.Seenivasaragavan.

Entity Framework 4.0 –DeferredLoadingEnabled property.

When you query for columns in a table , you actually retrieve only the columns from the table you requested. The related tables (Linked/Associations tables ) are not automatically fetched at the same time. suppose you might want to query a customers and a particular set of orders for that customers . you can do this by joining customers and orders in a query by forming the cross-product and retrieving all the relative bits of data as one large Record set. But these results are not entities.  when we use LINQ To SQL we can achieved this but     In Entity Framework  we do not have this options. Now with Entity Framework 4.0 we have it.

setting up the DeferredLoadingEnabled is true in context options

Here is how we can do this.  let us create EFM (Entity Framework Model)  from the well know DB called North wind. here  i am going to use  Customer and Order tables .

image 

The above Entity diagram shows  Customer and Order  relationship is  0 to many.

Now we will query the customer table and display the result on the webpage  with out enabling DeferredLoadingEnabled .

protected void Button1_Click(object sender, EventArgs e)
{
using (NorthwindEntities conn = new NorthwindEntities())
{

var query = from cust in conn.Customers
where cust.Country.ToUpper() ==
"USA"
select cust;


foreach (var item in query.ToList ())
{
Response.Write("Customer ID : " + item.CustomerID + " Total Number of Orders :<b> " + item.Orders.Count.ToString()+"</b></br>");
}

GridView1.DataSource = query.ToList();
GridView1.AutoGenerateColumns = true;
GridView1.DataBind();
}
}



image





Now we will query the customer table with DeferredLoadingEnabled  is set to ture.



protected voidButton1_Click(objectsender, EventArgs e)


      {





          using(NorthwindEntities conn = newNorthwindEntities())


          {


             conn.ContextOptions.DeferredLoadingEnabled = true;


              var query = fromcust inconn.Customers


                          wherecust.Country.ToUpper() ==
"USA"

                        
selectcust;





              foreach (var item inquery.ToList ())


              {





                  Response.Write("Customer ID :  "+ item.CustomerID + "    Total Number of Orders  :<b> "+ item.Orders.Count.ToString()+"</b></br>");


              }





              GridView1.DataSource = query.ToList();


              GridView1.AutoGenerateColumns = true;


              GridView1.DataBind();


          }


      }



after setting the DeferredLoadingEnabled  =true  the query able to bring corresponding order for each customer .




image



Nandri(Thanks)



SreenivasaRagavan