AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

Various enhancements #517

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
After using the current nightly build (1993) in a recent project I have made 
some enhancements to meet my requirements. I believe these enhancements would 
be worthwhile changes to the general community so I am including them here for 
your consideration. Note I have only changed the C# templates and SQL 
Procedures data access, changes need to be rolled into VB and Parameterised SQL 
templates for consistency.  Below is a summary of changes.

1.  New factory constructors “GetByCriteria”  which accept criteria classes
2.  Added IsSearch flag to critiera.  If set uses a different procedure name 
which perform search instead of match for string fields (i.e. like instead of 
equals). 
3.  Changed implementation of Exists when using Procedures to remove dependency 
on Select permission in SQL tables. Exists now uses Proc to perform exists 
command.  Proc name defined on Criteria
4.  Added Filter and Exists procedures for above.
5.  Added temporary ident value for ident primary keys. ID PK fields will have 
unique negative values until saved. Added to both root and child entity 
DataPortalCreate templates.
6.  Change implementation of MapDataReader and  MapDataReader ReadOnly to use 
generic LoadProperty method instead of non generic. This vastly improves 
performance on large lists due to CSLA internal reflection calls when using non 
generic method.  
7.  Change implementation for LoadProperty to use typed reader methods where 
possible to improve performance
8.  Change SystemType determination to use Map instead of internal method. 
Allows for handling of XML. XML mapped to String 
9.  Added support to reload parent member reference if related foreign key 
member property changed after parent member loaded.
10. Other minors change and fixes

For a complete list of changes please perform a file compare on the attached 
against build 1993.

Regards

Stephen

Original issue reported on code.google.com by comi...@gmail.com on 14 Oct 2010 at 9:22

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 18 Oct 2010 at 6:52

GoogleCodeExporter commented 9 years ago
Thanks for contributing this. I'm looking into this now.

Original comment by bniemyjski on 9 Mar 2012 at 1:35

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 9 Mar 2012 at 1:57

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2534.

Added GetByCriteria methods to the Lists.

Original comment by bniemyjski on 12 Mar 2012 at 5:17

GoogleCodeExporter commented 9 years ago
Hello,

Thanks a bunch for committing your changes. Would it be possible to expand on 
the following issues (E.G., why you made the changes and any issues you ran 
into) #2,3,4,5,6,7,8,9,10

It would be a very huge help, if you could update your templates to the latest 
nightly build of CSLA as we've changed quite a bit to ensure support for views 
and commands. Also if you could include each change over a few separate issues 
it would allow me to review these and talk about these issues in much greater 
detail in a shorter amount of time, allowing me to contribute these to core.

Original comment by bniemyjski on 12 Mar 2012 at 5:22

GoogleCodeExporter commented 9 years ago
Hello,

Thanks a bunch for committing your changes. Would it be possible to expand on 
the following issues (E.G., why you made the changes and any issues you ran 
into) #2,3,4,5,6,7,8,9,10

It would be a very huge help, if you could update your templates to the latest 
nightly build of CSLA as we've changed quite a bit to ensure support for views 
and commands. Also if you could include each change over a few separate issues 
it would allow me to review these and talk about these issues in much greater 
detail in a shorter amount of time, allowing me to contribute these to core.

Original comment by bniemyjski on 24 Apr 2012 at 1:36

GoogleCodeExporter commented 9 years ago
Hi Blake,

I've updated the changes to the current templates (R2632). This was no small 
task as there have been a lot of updates since I posted this 18 months ago. I 
haven't had time to test these thoroughly but they do produce working code for 
an existing project I based the original change on. Note only the C# templates 
have been updated.
I'm tied up on urgent project work so haven't got time to split these issues 
out. To answer the other Q's:
#2 - Search criteria required to generate search filters. Similar to select but 
all text fields (varchar, char etc) use SQL Like in where clause. Also if 
search requires custom fields (i.e. filter by fields not returned table such as 
parent fields, computed fields, custom logic etc) these can be added to the 
search procedure without impacting standard CRUD procs. I find complex search 
logic is best implemented in database procedures and separating the search from 
CRUD works well.
#3 – When using stored procedures for all data access (particularly when 
table level permission cannot be granted for security reasons) the Exists 
method needs to use a stored procedure and not SQL. The updated template 
ensures all Exists commands use a new Exists stored procedure which is based on 
the Select but with optimised SQL
#4 – Update Store Procedure templates for above. Note also changed 
implementation for GUID PK’s. These are now generated in the object and not 
returned from the DB. 
#5 – New objects need unique hash keys derived from primary key values. For 
idents I use an incremental negative number until the object is saved. This 
ensures all new objects in memory of unique within their type. Guid PK’s are 
also initialised with a new GUID and thus do not need to be returned from the 
SP’s
6# - Performance on large lists requires typed LoadProperty to bypass internal 
reflection methods
7# as above
8# XML SQL type mapped to System.String. 
9# Parent references need to be refreshed if related foreign key changed. I 
used a hashset to keep a list of parents that need to be refreshed when the 
foreign key property is updated.
10# Other changes include: Cache support to reduce database hits and improve 
performance for enumerations;  bug fix to correctly include search criteria on 
unique indexes when field names have been stripped of underscores; bug fix for 
parent and child property names when more than one foreign key relationship 
exists between the same tables (also changed parent member names back to 
"TableName"Member instead of “TableName”s), Bug fix for child insert/update 
where multiple FK’s to same parent generates duplicate method signatures 
(look for AssociationTypeComparer and BuildCommandParameters – updated to 
stop parent values being updated onto child when parent relationship cannot be 
determined due to multiple of same type. Need a better solution); Bug fix to 
return and update SQL computed fields after insert and update

I suggest you run a compare between the templates to view all changes. 

Thanks for following up on this. I'd like to see these changes back in the core 
so I don't have to apply updates to each release.

Original comment by comi...@gmail.com on 30 Apr 2012 at 11:07

Attachments:

GoogleCodeExporter commented 9 years ago
Hello,

Thank you so much for taking the time to submit the updated patch and respond 
to my questions. I'll look over these changes and see what I can do to get them 
into core. I'll keep updating this issue as I have more time / changes.

Original comment by bniemyjski on 30 Apr 2012 at 2:27

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 24 May 2012 at 3:11