Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing custom paging logic in BLL (not in stored procedures) for ObjectDataSource
    primarykey
    data
    text
    <p>So I've implemented objectDataSource custom paging in the DAL using stored proceedures like all the guides and tutorials describe, but I'm realizing that by putting your custom paging logic at the data access layer, you are limited on how much you can use your Domain model. </p> <p>For instance, I have a webform with a gridview that I want to display every Customer (CustomerId) that's belongs to a specific Office (OfficeId) and the status of their Order (OrderId) if they have one.</p> <p>So in my services layer I could fill a DTO list like (I'm a newbie when it comes to DDD so I'm sure this design isn't great but bear with me):</p> <p>ObjectDataSource SelectMethod tied to:</p> <pre><code>public List&lt;CustomerAndOrderDTO&gt; GetCustomersByOffice(int officeId, int startPageIndex, int maxiumRows) { List&lt;CustomerAndOrderDTO&gt; customerAndOrderDTO = null; List&lt;Customer&gt; customers = Customer.GetCustomersByOffice(int officeId); foreach (Customer customer in customers) { customerAndOrderDTO.Add(new CustomerAndOrderDTO(customer)); } return customerAndOrderDTO; } </code></pre> <p>And this is the DTO class:</p> <pre><code> public CustomerAndOrderDTO { public int OrderId {get; set;} public int CustomerId {get; set;} public CustomerAndOrderDTO(Customer customer) { CustomerId = customer.Id; Order order = customer.GetOrder(); OrderId = order.Id; } } </code></pre> <p>Pretty simple code and you get all the flexibility and power of the domain model plus validation and persistence checking while staying in the BLL.</p> <p>Even if you wanted to ignore the benefits of aggregating your objects in the domain and just combine the data at the stored procedure level like select * from Customers left join Orders on .... left join Office on ... where.... you'd end up writing a million extension methods that implement paging for every possible combination like CustomersOrdersByOfficePaged, CustomersOrdersByAccountDatePaged, etc...</p> <p>So am I just doing it wrong to begin with? Or does paging at the Service layer make sense? If so, how does one implement it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload