TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Fun with LLBLGen Pro and Visual Studio 2005

My opinion about O/R Mappers has been changing rapidly since I started researching LLBLGen Pro. In fact, I just persuaded a client to buy it. Why? Well, there's lot's of reasons, but here's one reason in a nice demo format...

Within five minutes, I can generate an scalable object model using the adapter scenario along with a set of manager templates (that someone was nice enough to write and share with the rest of us). Then create a VS2005 Web project that uses the ObjectDataSource control that is bound to by a GridView. The ObjectDataSource points to the following method like so....

using System.Collections.Generic;

using NorthWind.EntityClasses;

using NorthWind.Core.Managers;

using NorthWind.HelperClasses;

 

public class Customers

{

    public List<CustomersEntity> GetCustomers() {

        EntityCollection entities = CustomersManager.FetchCollection();

        List<CustomersEntity> customers = new List<CustomersEntity>();

        foreach (CustomersEntity cust in entities)

            customers.Add(cust);

        return customers;

    }

}


 

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetCustomers" TypeName="Customers"></asp:ObjectDataSource>

 

<asp:GridView AutoGenerateColumns="false" DataSourceID="ObjectDataSource1" ID="GridView1" runat="server">

    <Columns>

        <asp:BoundField DataField="CustomerID"></asp:BoundField>

        <asp:BoundField DataField="CompanyName"></asp:BoundField>

    </Columns>

</asp:GridView>


As you can see, I'm binding against a generic list just to have some fun with generics, but I could just as easily write the GetCustomers() method to simply return an EntityCollection object...
 

public EntityCollection GetCustomers() {

    return CustomersManager.FetchCollection();

}

Or I can go really crazy and have no C# code at all like this...

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="FetchCollection" TypeName="NorthWind.Core.Managers.CustomersManager" />

 

<asp:GridView AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" ID="GridView1" runat="server">

    <Columns>

        <asp:BoundField DataField="CustomerID"></asp:BoundField>

        <asp:BoundField DataField="CompanyName"></asp:BoundField>

    </Columns>

</asp:GridView>

Pretty cool stuff, huh?  :-)


Digg!

posted on Sunday, March 27, 2005 11:56 AM

Feedback

# re: Fun with LLBLGen Pro and Visual Studio 2005 8/8/2006 11:43 AM bonder

Dude, that kicks more ass than an ass-kicking machine stuck in overdrive! :) Thanks for the great code samples, and you are going to the top of my blogroll! :)