Telerik Releases a new Visual Entity Designer

Posted on Dot net Slackers See other posts from Dot net Slackers
Published on Mon, 22 Mar 2010 00:00:00 GMT Indexed on 2010/03/22 15:01 UTC
Read the original article Hit count: 329

Filed under:

Love LINQ to SQL but are concerned that it is a second class citizen? Need to connect to more databases other than SQL Server? Think that the Entity Framework is too complex? Want a domain model designer for data access that is easy, yet powerful? Then the Telerik Visual Entity Designer is for you.

Built on top of Telerik OpenAccess ORM, a very mature and robust product, Teleriks Visual Entity Designer is a new way to build your domain model that is very powerful and also real easy to use. How easy? Ill show you here.

First Look: Using the Telerik Visual Entity Designer

To get started, you need to install the Telerik OpenAccess ORM Q1 release for Visual Studio 2008 or 2010. You dont need to use any of the Telerik OpenAccess wizards, designers, or using statements. Just right click on your project and select Add|New Item from the context menu. Choose Telerik OpenAccess Domain Model from the Visual Studio project templates.

image

(Note to existing OpenAccess users, dont run the Enable ORM wizard or any other OpenAccess menu unless you are building OpenAccess Entities.)

You will then have to specify the database backend (SQL Server, SQL Azure, Oracle, MySQL, etc) and connection.

image

After you establish your connection, select the database objects you want to add to your domain model. You can also name your model, by default it will be NameofyourdatabaseEntityDiagrams.

image

You can click finish here if you are comfortable, or tweak some advanced settings. Many users of domain models like to add prefixes and suffixes to classes, fields, and properties as well as handle pluralization. I personally accept the defaults, however, I hate how DBAs force underscores on me, so I click on the option to remove them.

image

You can also tweak your namespace, mapping options, and define your own code generation template to gain further control over the outputted code. This is a very powerful feature, but for now, I will just accept the defaults.

 image

When we click finish, you can see your domain model as a file with the .rlinq extension in the Solution Explorer.

image

You can also bring up the visual designer to view or further tweak your model by double clicking on the model in the Solution Explorer. 

image

Time to use the model!

Writing a LINQ Query

Programming against the domain model is very simple using LINQ. Just set a reference to the model (line 12 of the code below) and write a standard LINQ statement (lines 14-16).  (OpenAccess users: notice the you dont need any using statements for OpenAccess or an IObjectScope, just raw LINQ against your model.)

 1: using System;
 2: using System.Linq;
 3: //no need for an
OpenAccess using statement
 4:  
 5: namespace ConsoleApplication3
 6: {
 7:  class Program
 8:  {
 9:  static void Main(string[]
args)
 10:  {
 11:  //a reference to
the data context
 12:  NorthwindEntityDiagrams dat = new NorthwindEntityDiagrams();
 13:  //LINQ Statement
 14:  var result = from c in dat.Customers
 15:  where c.Country
== "Germany"
 16:  select c;
 17:  
 18:  //Print out the company name
 19:  foreach (var
cust in result)
 20:  {
 21:  Console.WriteLine("Company
Name: " + cust.CompanyName);
 22:  }
 23:  //keep the console
window open
 24:  Console.Read();
 25:  }
 26:  }
 27: }

Lines 19-24 loop through the result of our LINQ query and displays the results.

image

Thats it! All of the super powerful features of OpenAccess are available to you to further enhance your experience, however, in most cases this is all you need.

In future posts I will show how to use the Visual Designer with some other scenarios. Stay tuned.

Enjoy!

Technorati Tags: ,,
Bookmark and Share  height=

Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.



Email this Article

© Dot net Slackers or respective owner