Project Description
Linquify is a Visual Studio 2008/2010 Addin and C# .NET business class / DTO generator for LINQ to SQL and the Entity Framework. It supports rapid development of .NET and ASP .NET web application data layers allowing you to query as: Person.Load(5); Person.Name="n"; Person.Save()

Official Project Home for Linquify

http://www.primaryobjects.com/linquify.aspx

Manual Visual Studio Add-in Install Instructions
http://www.primaryobjects.com/linquify.aspx#MANUALINSTALL

Introduction

Linquify is a C# .NET business class generator for LINQ to SQL and the Entity Framework, helping to support rapid development of .NET and ASP .NET web application data layers. Linquify is free for use under the LGPL.

Linquify installs as a Visual Studio 2008/2010 addin, which allows you to select your LINQ to SQL dbml file or Entity Framework edmx file and automatically generate a set of easy to use business classes. The generated classes allow you to support a complete 3-tier software architecture and simple handling of database objects, with full support for LINQ queries. Customizations to the generated classes can be easily made within the generated user partial classes.

Linquify Key Features

  • Visual Studio 2008/2010 Addin for easy generation.
  • Compatible with LINQ to SQL and the Entity Framework.
  • Compatible with SQL Server, MySQL, Oracle, and any other compatible database platform (uses the Entity Framework default provider or LINQ2SQL with DbLinq).
  • Automatic generation of Types library, containing business classes, and supporting 3-tier architecture.
  • Simple Load(), Save(), Delete() methods for making database calls.
  • Full support for LINQ queries.
  • Full support for Entity Framework foreign keys.
  • Full support for passing DTO objects within Session and between postbacks.
  • Optimized SQL query execution.
  • Includes generated partial classes for customizing business objects.

Quick Start Tutorial

http://www.primaryobjects.com/linquify.aspx#tutorial

A Quick Glance at Using Linquify

// Instantiate a Linquify business object. 
Person person = new Person(); 

// Select and Update. 
person.Load(10); 
person.FirstName = "John"; 
person.Save(); 

// Update again. 
person.LastName = "Doe"; 
person.Save(); 

// Insert new person with auto-incremented ID (works for Guids too). 
person = new Person(null, "John", "Doe"); 
person.Save(); 

// Insert new person with ID 10, explicit insert.
person = new Person(10, "John", "Doe");
person.Insert();

// Select and Delete the person with ID = 10 using the Where clause. 
person.WhereClause.ID = 10; 
List<Person> personList = person.Find(); 
foreach (Person aPerson in personList) 
{ 
   aPerson.Delete(); 
} 

// Select the first 2 people with the last name containing 'Doe' using the Where clause. 
person.WhereClause.MyWhere = "WHERE LastName LIKE '%Doe%'"; 
person.WhereClause.MyTop = "TOP 2"; 
List<Person> personList = person.Find(); 
foreach (Person aPerson in personList) 
{ 
    Console.WriteLine(aPerson.FirstName);
} 

// Create your own custom method in the partial class to query using LINQ. 
public partial class Person 
{ 
   public static Person GetTestPerson(int id) 
   { 
      using (HelloWorld.DB.PersonContext context = new HelloWorld.DB.PersonContext()) 
      { 
         var result = from p in context.Person 
                      where p.ID == id 
                      select p; 

         return new Person(new BaseTypes.Person(result.ToList()[0])); 
      } 
   } 
} 

// Calling custom method from partial class. 
Person person = Person.GetTestPerson(10); 
person.LastName "Doe Jr."; 
person.Save(); 

// Binding to a GridView with all people is easy. 
myGridView.DataSource = person.ToList(); 
myGridView.DataBind(); 

Embedding Business Objects

// Embedding an Address business class within Person, forming a complete entity. 
public partial class Person 
{ 
   public Address Address { get; set; } 

   protected override void OnInitializeComplete() 
   { 
      // Load the address. 
      if (AddressId != null && AddressId != Guid.Empty) 
      { 
         Address = new Address(); 
         Address.Load(AddressId.GetValueOrDefault()); 
      } 

      base.OnInitializeComplete(); 
   } 

   protected override void OnSave() 
   { 
      if (Address != null) 
      { 
         // Save the address. 
         Address.Save(); 

         // Fill in our foreign key. 
         AddressId = Address.AddressId; 
      } 

      base.OnSave(); 
   } 
}

Transactions

using (HelloWorld.DB.PersonContext context = new HelloWorld.DB.PersonContext()) 
{
     Person person = new Person();
     person.SetTransactionContext(_context);

     foreach (Person p in person.ToList())
     {
          p.Age++;
          p.Save();
     }

     Address address = new Address(null, "123 Main St.", "Newark", "NJ", 12345);
     address.SetTransactionContext(_context);
     address.Save();
     
     person.Load(123);
     person.AddressId = address.AddressId;
     person.Save();

     person.Commit();
}

For more code samples, see the project homepage http://www.primaryobjects.com/linquify.aspx

Additional Tutorials

Populating a DropDownList with Linquify and the Entity Framework in C# ASP .NET
http://www.primaryobjects.com/CMS/Article117.aspx

Creating Silverlight Web Applications with Linquify, LINQ to SQL, WCF
http://www.primaryobjects.com/CMS/Article116.aspx

About the Author
Linquify and associated article(s) were written by Kory Becker, .NET software architect and founder of Primary Objects.

Last edited Jul 23, 2010 at 6:35 PM by PrimaryObjects, version 15