Custom DAO

Last post 05-09-2008 12:46 PM by scothu. 6 replies.

Sort Posts:

  • Custom DAO

    05-08-2008, 7:57 AM
    • Loading...
    • M.Steyer
    • Joined on 05-08-2008, 11:56 AM
    • Posts 3

    Hi,

    is there a way to use CustomDataAccessObjects with ASP.NET Dynamic Data ?

    Regards,
    Manfred

  • Re: Custom DAO

    05-08-2008, 11:13 AM
    • Loading...
    • davidebb
    • Joined on 06-11-2002, 8:31 AM
    • Redmond, WA
    • Posts 859
    • AspNetTeam

    Hi Manfred,

    Can you give more details about what you are trying to do?  Dynamic Data does have an extensible layer that allows it to work with 3rd party O/R mappers.  e.g. it will work with LLBLGen Pro.

    David

  • Re: Custom DAO

    05-08-2008, 12:12 PM
    • Loading...
    • M.Steyer
    • Joined on 05-08-2008, 11:56 AM
    • Posts 3

    Hi,

    I want that Dynamic Data does not access my Tables directly but indirectly via a Custom DAO-Class like the following one:

    class SomeTableDAO {

     SomeEntity saveSomeEntity(...) { ... }

     SomeEntity findSomeEntityById(int id) { ... }

     SomeEntity findSomeEntityByAnotherLinkedEntity(AnotherLinkedEntityId id) { ... }

    }

     

    Is there a way to do such things?

     

    Regards,

    Manfred

  • Re: Custom DAO

    05-08-2008, 1:59 PM
    • Loading...
    • craigshoemaker
    • Joined on 09-27-2007, 3:25 PM
    • Southern California, USA
    • Posts 14

    David:

    Do you have any further information on the extensibility for the data layer? Does it interface with SubSonic yet?

     - Craig


     

  • Re: Custom DAO

    05-08-2008, 3:57 PM
    • Loading...
    • davidebb
    • Joined on 06-11-2002, 8:31 AM
    • Redmond, WA
    • Posts 859
    • AspNetTeam

    Manfred: Note that Dynamic Data doesn't directly access your tables.  Instead, it talks to Linq To Sql or Entity Framework (or 3rd party) O/R mapper classes.  Entity Framework lets you create conceptual models that are quite different from the underlying database.

    Craig: implementing a layer imvolves implementing a System.Web.DynamicData.ModelProviders.DataModelProvider.  We will have some good samples out soon.  We don't have Subsonic support at this time, but it could potentially come down the road.

    David

  • Re: Custom DAO

    05-09-2008, 4:59 AM
    • Loading...
    • M.Steyer
    • Joined on 05-08-2008, 11:56 AM
    • Posts 3

    Hi David,

     ok, but let's say I want that saving a Product should result in updating a Product in the Product-Table AND in inserting a row in the product-history-table. How to achieve that?

    I've seen in yor MIX-Webcast, that there is a way to create an MVC-Controller for specific entities. Can I use this mechanism for that?

     

    Thx an best wishes,

    Manfred

  • Re: Custom DAO

    05-09-2008, 12:46 PM
    Answer
    • Loading...
    • scothu
    • Joined on 12-10-2007, 1:54 AM
    • Redmond, WA
    • Posts 109

    You have a couple of options for this:

    1) Add a database trigger to inserting on the Product table to automatically add the entry in the history table.

    2) For the Product table set the Insert operations to go through a stored procedure (you can do this in the Linq to SQL designer). Have your stored procedure modify both tables.

    3) You can also create a custom Insert or ListDetails page and capture the Inserting event on the DetailsView and when that is fired have some logic that updates the History table.

     

    Scott Hunter
    ASP.NET
Page 1 of 1 (7 items)