DLinq Designer - Visual Drag and Drop O/R Mapping Design Surface in Visual Studio 2005 - DLinq Tutorials

DLinq Designer - Visual Drag and Drop O/R Mapping Design Surface in Visual Studio 2005 - DLinq Tutorials

by David Hayden ( C# .NET Programmer )

Filed: LINQ, O/R Mapper

 

The May 2006 CTP for LINQ includes a really cool DLinq Designer where you can build DLinq Classes manually, or more importantly, drag and drop existing tables on the DLinq Designer surface and have the c# or vb code for the classes automatically generated for you in the background.

If we take my previous example of a movie collection discussed in the following Dlinq tutorials:

 

I can add a DLinqObjects Item to my Visual Studio 2005 LINQ Windows application:

 

 

and drag my Genres and Movies SQL Server Tables to the DLinq Designer surface:

 

 

As you make changes on the DLinq Designer Surface, changes are made to the source code of the DLinq Classes in real-time:

 

[System.Data.DLinq.Table(Name="Genres")]
public partial class Genre :
  System.Data.DLinq.INotifyPropertyChanging,
  System.ComponentModel.INotifyPropertyChanged {
    
    private int _ID;
    
    private string _Name;
    
    private System.Data.DLinq.EntitySet<Movie> _Movies;
    
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public Genre() {
        this._Movies = new System.Data.DLinq.
        EntitySet<Movie>(new System.Data.DLinq.Notification
        <Movie>(this.Attach_Movies), 
        new System.Data.DLinq.Notification<Movie>
        (this.Attach_Movies));
    }
    
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [System.Data.DLinq.Column(Name="GenreId",
    Storage="_ID", DBType="int NOT NULL IDENTITY",
    Id=true, AutoGen=true)]
    public virtual int ID {
        get {
            return this._ID;
        }
        set {
            if ((this._ID != value)) {
                this.OnPropertyChanging("ID");
                this._ID = value;
                this.OnPropertyChanged("ID");
            }
        }
    }

...

 

Conclusion

There are a couple of really good options for building DLinq Classes based on existing tables in SQL Server: SqlMetal or DLinq Designer.

 

Source: David Hayden ( C# .NET Programmer )

Filed: LINQ, O/R Mapper

 

posted on Sunday, May 21, 2006 3:31 PM

Main

News

Green Tea

.NET Development

Enterprise Library

Patterns & Practices