CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Best tact for Hierarchical queries

    rated by 0 users
    Answered (Not Verified) This post has 0 verified answers | 3 Replies | 3 Followers

    Top 500 Contributor
    27 Posts
    csmith1 posted on Thu, Mar 8 2012 11:53 AM

    I need to query an EditableRootList by hierarchical child attributes.

    An example from Using CSLA would be a  Invoice->LineItems->LineItem.

    I would like to return all Invoices for this month that have an LineItem Amount over $500.00.

    Should I make a Command or this a Unit of Work?

    I do not see in Using CSLA an example of how tackle this type of problem.

     

    All Replies

    Top 10 Contributor
    9,475 Posts

    You'll obviously have an InvoiceList object that is the list of Invoice objects right? Or maybe a list of read-only InvoiceInfo objects?

    The fetch method for the InvoiceList object is where you'd execute the database query necessary to retrieve the filtered list of invoice data. All the real work should occur in the query (in the database).

    Rocky

    Top 500 Contributor
    27 Posts

    I understand the work will be done in the server side in my case in the DAL. Usually I have seen top down query where one selects an invoice. Then selects invoice row. I like select and return a sub-set invoices with the children already loaded.  I am thinking of creating a command that contains the criteria for the root and each child in hierarchy. I have a view in the db that joins all the tables together. I would select against the view. Then walk down the results filling in the selected parent then selected children then selected grandchildren. I would think this is a fairly common problem. Was not sure if there was some advantage to using the unit of work over the command. I was wonder if someone had come up with a different way to return result in a hierarchical set.   

    Top 25 Contributor
    498 Posts

    Hi,

    Have a look at DeepLoad sample v.2.0.0

    This sample is generated by CslaGenFork. You can use the generated code as a guide. CslaGenFork doesn't support your needs directly, meaning you would have to edit the generated stored procedure in order return only Invoide WHERE "LineItem Amount over $500.00". Besides that change in the search criteria, CslaGenFork can generate code to fetch all data in a single round trip to the database. If you don't like code generators, have a look at the sample to see how it's done.

    Tiago Freitas Leal, CslaGenFork (Open Source CSLA code generator)

    Page 1 of 1 (4 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems