Linq to Sql templates posted!

Posts   
 
    
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39771
Joined: 17-Aug-2003
# Posted on: 23-Apr-2008 12:21:27   

Linq to Sql support templates for v2.5 are now available in the customer area. We'll release them to the public site in a couple of weeks if no more bugs are found wink

To download: go to the customer area -> 2.5 section -> tasks and templates

Linq to SQL templates and templatebindings

Released on: 23-apr-2008 For LLBLGen Pro version: v2.5 Created by: Solutions Design, http://www.llblgen.com Target language: C#

Purpose

These templates allow you to generate code for Linq to Sql using any LLBLGen Pro project. You can use the LLBLGen Pro's designer to create and maintain a project and generate code directly from the designer using these templates. This allows you to use the powerful catalog refreshing capabilities as well as the other features of the LLBLGen Pro designer.

Linq to Sql's code generator isn't template based nor does it split up the classes in one class-per-file. These templates allow you to alter the generated code and also give you one class per file.

Installation

Unpack the archive in the LLBLGen Pro installation folder. It will tell you that there's already a folder called 'Tasks' and a folder called 'Templates'. Click 'Yes' when you're asked to overwrite these folder declarations: doing so will keep the current folders and will add the archive's contents to these folders.

You can also unpack the Tasks folder in the archive to another folder where you keep your additional tasks files, as long as it's a folder reachable when you want to generate code inside LLBLGen Pro.

Requirements

LLBLGen Pro v2.5 of January 1st or later. Linq to Sql only works on SqlServer, so using these templates on a project other than a SqlServer project won't work.

Compatibility and caveats

Linq to Sql doesn't support m:n relations nor inheritance with hierarchy type TargetPerEntity. It also doesn't support abstract inheritance hierarchy roots. Linq to Sql also doesn't support .NET UDT typed fields. Linq to Sql doesn't have the concept of a TypedList, so these are ignored.

The templates will work around these limitations by either ignoring the information (as with the inheritance hierarchies) or try to make it work (ignore 'abstract' on root types)

LLBLGen Pro's designer currently doesn't allow you to specify stored procedure calls as persistence methods, so you can't use a stored procedure for insert/update/delete of an entity. Linq to Sql's designer uses a trick to obtain the resultset type of a stored procedure: SET FMTONLY ON;exec proc;SET FMTONLY OFF. The downside of this is that with procs which use temptables or have multiple resultsets, it can go wrong. LLBLGen Pro therefore dropped this feature some years ago and therefore it doesn't have any type information about the resultset. It therefore is currently not possible to generate stored procedure calls into the Linq to Sql code with proper type information as this meta-data isn't available.

Usage

  • Create or open a SqlServer based LLBLGen Pro project and press F7 or select Project -> Generate
  • Under 'Template group' select 'Linq to Sql'
  • Under 'Target platform' select '.NET 3.5'
  • Specify a root namespace and a destination folder. Use a separate folder from your main solution for the generated code as these templates generate a separate project.
  • At tab 3, you now have a preset available to you which contains the tasks.
  • Click Start generator.

You'll get a complete VS.NET 2008 class library generated. It contains a folder, 'EntityClasses' which contains per entity type a class file. Also generated are a Mappings.dbml file which contains the mapping information and a DataContext.cs file which contains the datacontext class.

To use it in your own solution, you've to make sure that your application's config file contains a connection string element for the ConnectionStrings section. You should copy the connection string from the generated app.config file to your application's config file and give the connection string the same name as the element in the generated app.config file, e.g. 'Main.ConnectionString'. After that, reference the generated VS.NET 2008 project and you're set to use the generated code!

Support

These templates are an official release, so if you have questions, remarks, bugreports etc., please post a message in one of the forums at http://www.llblgen.com/tinyforum

FAQ

Q: Is this the end of your own o/r mapper framework? A: No, not at all. We will keep on supporting our own framework as we think it's the best o/r mapper framework out there. We just wrote these templates to allow users of another o/r mapper framework, Linq to Sql, to use our designer's power as Linq to Sql's designer lacks model refreshing support.

Q: Do you plan to create more templates like these in the future? A: We indeed have plans to release more templates for other frameworks, also with more advanced features than these initial templates.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39771
Joined: 17-Aug-2003
# Posted on: 24-Apr-2008 09:59:45   

The archive has been updated slightly as some files were in the wrong folder flushed

Frans Bouma | Lead developer LLBLGen Pro
Posts: 1263
Joined: 10-Mar-2006
# Posted on: 26-Apr-2008 05:56:22   

I am very confused.

What are these and how do they relate do 2.6 release?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39771
Joined: 17-Aug-2003
# Posted on: 26-Apr-2008 10:50:34   

WayneBrantley wrote:

I am very confused.

What are these and how do they relate do 2.6 release?

They are a simple set of templates which allow you to use the llblgen pro designer to create a normal project and generate linq to sql code instead of code for our own framework, if you want to.

For users who use our own framework they're probably not that important, but for people who have to use linq to sql but also need entity model refreshing when the database changes have an easier life now as linq to sql's designer doesn't support catalog refreshing wink

They don't really relate to v2.6, I wrote them in a day or so. We'll include them in v2.6 as a separate template group.

Frans Bouma | Lead developer LLBLGen Pro