sorting query results

Dec 2, 2010 at 7:25 PM

Hi,

I'm pretty new to both CSLA and to your great T4 extension so please forgive if the question is stupid.

The generated code seems to allow for hooks for customizing operations by using partial classes. I want to read in a list of items from the database, but sort the results. I'm using the static function GetAll() in the generated code. The hooks would seem to be the BeforeRead(IEnumerable<T> data) and AfterRead() functions, but since data is passed by value, I can't change the query ala data=data.OrderBy(). Of course I could change the Read function itself, but then my changes would be overriden next time code is generated. Any suggestions?

Also, what is the purpose behind the static T Get(IEnumberable<T> data) function?

Thanks again for this project,

 

pablo

Coordinator
Dec 3, 2010 at 8:43 AM

Hi talfulano.

Thanks for your suggestion. I've changed the template and added reference parameters to partial methods. You can download latest template from the source code repository or download 1.0.2. ALPHA version and reinstall extension.

Note: You can always add custom methods to partial classes in order to load entities using custom queries or stored procedures.

Purpose behind static Get(IEnumerable) methods is to load navigation and child properties. You can also use this method when writing custom load methods, or creating custom properties.

Regards,

Josip