Im working from an existing code base in order to replicate and implement the Message based Request\Response architecture and wondered if I could be corrected (if needed) on the below code snippet next to my comments please.
// Method declaration which Returns the CustomerResponse type and accepts an input arguement of type CustomerRequest.
public CustomerResponse GetCustomers(CustomerRequest request)
// Local variable declaration which creates an instance of the CustomerReponse and stores the object in the local variable named response.
var response = new CustomerResponse(request.RequestId);
// Sets or Sets the Criteria and which stores it in the local variable criteria?
var criteria = request.Criteria as CustomerCriteria;
// Gets the SortExpression property and stores it in the sort local variable
string sort = criteria.SortExpression;
// Checks if the LoadOptions property contains a string name Customers.
if (request.LoadOptions.Contains("Customers"))
// Creates an enumerable of type Customer called customers.
IEnumerable
// If the Criteria does not use the IncludeOrderStatistics property
if (!criteria.IncludeOrderStatistics)
// Invoke the GetCustomers and store the return value in the local variable named customers
customers = _customerDao.GetCustomers(sort);
// Otherise store the GetCustomersWithOrderStatistics in the customers local variable instead
customers = _customerDao.GetCustomersWithOrderStatistics(sort);
/ Set the response Customer property to the customers local variable and run a lambda which will translate to the correct DTO object.
response.Customers = customers.Select(c => Mapper.ToDataTransferObject(c)).ToList();
// Get and store the return value of the Getcustomer method into the local variable named customer.
var customer = _customerDao.GetCustomer(criteria.CustomerId);
// Check if the request LoadOptions property holds the string Orders
if (request.LoadOptions.Contains("Orders"))
// Set the customer Orders property to the GetOrdersByCustomer method.
customer.Orders = _orderDao.GetOrdersByCustomer(customer.CustomerId);
// Set the ToDTO method to the response Customer property.
response.Customer = Mapper.ToDataTransferObject(customer);
// Return the value of the response object.
return response;
Thanks!
VulpesPosted Mar 7, 2012, 10:34 AM
VulpesPosted Mar 9, 2012, 11:03 AM
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.sortexpression.aspx
Amit ChoudharyPosted Mar 9, 2012, 10:59 AM
VulpesPosted Mar 9, 2012, 10:40 AM
But, I'd expect a SortExpression property to be expressing how some table (perhaps 'criteria' here) is automatically sorted as elements are added to it.
I'd also expect it to take this sort of form:
"Column1 Asc, Column2 Desc"
which means sort first by Column1 in ascending order and then (if two rows have the same value for Column1) by Column2 in descending order.
It might also be as simple as this:
"Column3"
which means sort by Column3 in ascending order (usually the default).
Guest UserPosted Mar 9, 2012, 10:26 AM
Given the expression declaration
string sort = criteria.SortExpression;
There is no logic defined in the SortExpression its just simply an Automatic property, so what exactly would the local variable sort be storing? I dont see what the benefit would be of storing this property, what is to be had from it?
Thanks
Steven