icon

CodeTrigger   Forum

Code Generation For C#, WPF, WCF, SQL SERVER/ORACLE/MYSQL and Visual Studio 2013-2017

migrator

all messages by user

03/12/2017
Topic:
Binding Foreign key fields to DropDown

migrator
migrator
Administrator
Looking at the code generated I need guidance on how to do foreign key looks For example all the generated UI screens display the primary key, none seem to support foreign key lookups, etc
03/12/2017
Topic:
Binding Foreign key fields to DropDown

migrator
migrator
Administrator
Hi
If I understand you correctly, you are wondering how to write a query to lookup by foreign key, potentially to bind the results to a drop down, since MVC sample generator does not provide this facility out of the box.

The page https://www.codetrigger.com/criteriaqueryapi.aspx
has plenty of examples on how to use the CriteriaQuery Api for different types of queries.

If you have the value of the foreign key then its a straightforward query

IList<BOProduct> boProducts = new Criteria<BOProduct>().Add(Expression.Eq("Category", "Fitness")).List<BOProduct>();

gives you a list of Products based on the Category foreign key: 'Fitness'

There are other examples of queries using subqueries, or selection from a table based on values in other tables etc.


If you are using MVC pattern, after code generation you would then extend the controller with some methods to run these custom queries and return data for populating the drop downs. Add methods similar to the generated methods, that take a foreign key value as parameter and return a list of values. This list you then bind to a html drop down list.

The section 'Customising Generated Code' on the page https://www.codetrigger.com/features.aspx
gives you directions on your options for customising code thats already been generated. Basically your options are either to create new files with partial classes containing the new code, or modify the generated files directly and then add them to the 'escaped files' list (Pro license version only) so that your changes do not get over-written.
edited by migrator on 12/3/2017
03/12/2017
Topic:
Transferring hierarchical data structure across

migrator
migrator
Administrator
This is an interesting question. We have created a tutorial/sample page about how you can do this:
Transferring deep collections using Wcf
and
Transferring deep collections using restApi
edited by migrator on 12/3/2017
04/12/2017
Topic:
Oracle Number(31) column used for ID column

migrator
migrator
Administrator
PeopleSoft tables contain Number(31) columns that it uses for “ID” type columns. CodeTrigger treats these as .Net decimal types which causes data overflow issues in the business layer. One of the approaches we have used with these colums is to apply Oracle to_char functions and treat them as strings. Can something like this be done with CodeTrigger?
04/12/2017
Topic:
Oracle Number(31) column used for ID column

migrator
migrator
Administrator
If you look in the generated Data Access Base Class: XXXXBaseData.Cs, you will see a section called BoxRowValue. This is where some special processing is placed to handle Number(1). The function is designed for such cases, so I think the best approach might be to look at that function and make some changes in there to handle Number(31). Might be best to just write a safe convert to decimal in that function for the Number(31) case. Please let me know how you get on as we would be very interested in this UseCase.


#region oracle parameter helpers
protected static object BoxRowValue(object value, string entityName, string fieldName)
{
//write any necessary conversion code
if(entityName == "sometablename" && fieldName == anumber31fieldName) return mySafeConvertFunction(value);

//for eg change up from NUMBER(1) to boolean if required
return (object)(value != null ? ((short)value != 0) : default(bool));
}

protected virtual object UnboxOracleParam(OracleParameter oracleParam, string entityName)
{
...
...
}
04/12/2017
Topic:
Oracle Number(31) column used for ID column

migrator
migrator
Administrator
UPDATE
Release 4.8.6.2 (June 2016)
Added Support for non native Boolean field representation for Oracle - using Number(1) convention
Added support for Identity Fields in Oracle 12+
edited by migrator on 12/4/2017
04/12/2017
Topic:
Support for Composite keys

migrator
migrator
Administrator
We required the composite key feature as only single Identity does not fulfill our requirements, We cant seem to get it working in our CodeTrigger project, anyone having the same issue or know any workarounds ?
04/12/2017
Topic:
Support for Composite keys

migrator
migrator
Administrator
CodeTrigger does not support Composite Keys, in either the Trial Version, Free standard version, or Professional version.
This is a apparently a design decision and has been so since version 1.1


Adding an Identity or Unique or Computed column on your tables will likely give you the most of the functionality you require.
edited by migrator on 12/4/2017
04/12/2017
Topic:
Naked Object Pattern

migrator
migrator
Administrator
Hi Ellie,

Hi
While researching the possible frameworks that may save me development time, I came across the Naked Object Framework (NOF) on http://nakedobjects.net/home/index.shtml

What is the difference between NOF and CodeTrigger? Are you able to integrate the Naked Objects pattern to existing patterns / ideas into CodeTrigger in such a way that reduces the work that need be done on developing UI in Visual Studio?
04/12/2017
Topic:
Naked Object Pattern

migrator
migrator
Administrator
Hi
Although CodeTrigger doesnt explicitly support the Naked Objects pattern, after a brief analysis it appears that the approach taken by CodeTrigger is compatible with the pattern as observed in some of the literature online.
However you might find that the sample UI's do not provide much UI centric support for managing relationships and collections which you may (or may not) find in software provided by Naked Objects framework tool vendors.

It would be interesting to know how you get on with this approach should you decide to proceed with implementing such a pattern using CodeTrigger.
04/12/2017
Topic:
Generating Code from SparxSystems EA Data Models

migrator
migrator
Administrator
CodeTrigger (CT)generates code from an existing implemented database. The value that the CT EA Add-In may deliver is the ability to generate an application from a relational data model in EA without a connection to a database. The reason for this request is simply that it brings the design of the data model itself into the iterative design cycle. There is a general assumption that the data model design and the database schema is fixed but in my experience, its development goes through several cycles which change may also be influenced by what the users see in the forms.


There is also an assumption that most of your customers have an existing database. In fact I see your tools enabling the creation of next generation line of business applications from industry models. I should know as my day job is the development of corporate and industry models in the Aviation industry. I work for an Airport. In this scenario, the tools required include the Sparxsystems EA, CT for EA and Visual Studio. EA holds the corporate information models and the relational data models. The CT for EA generates the application from the models in EA. Visual Studio builds and runs the application. The process is model--> generate --> build --> review with end users. This process eliminates interaction with a database in the early iterations of application development. When the end user is happy with the prototype forms, the developer may then generate the database schema from the final data model, create the database, populate it with data and test.


The change in process and the productivity gain delivered by this approach and supported by CT for EA is the source for value To achieve the functionality described, CT for EA will be getting its schema information from the EA database. I am happy to work with you to test this functionality
04/12/2017
Topic:
Generating Code from SparxSystems EA Data Models

migrator
migrator
Administrator
Hi
Thanks for your email. I do understand this feature request, indeed we had it as a possible on our dev board for a while before dropping it. I will put it back on there for further consideration. However, the reason it was not implemented as such previously was because
(a) it would introduce a different wotkflow between EA CodeTrigger and Visual Studio CodeTrigger
(b) Considering that the only difference you would see between successive iterations of changing your model and regenerating with CodeTrigger would be additional menu items (if you added a new table) or an extra column on the grid (if you added an extra field to model), this did not provide a compelling value add to the iterative process.
(c) Some elements in the code are dependent on the exact flavour of the database, ie the code generated to support Skip and Take record paging is different depending on the database version. Therefore the user would be required a more complete database model than otherwise might be the case.

Therefore, although it is an attractive feature, for these reasons it is yet to pass our prioritisation and cost benefit analysis.

I will keep you informed if any decisions are taken about this.
04/12/2017
Topic:
Using CriteriaApi queries across the WCF boundary

migrator
migrator
Administrator
Hi, We actually trying to use the CriteriaQuery API with the WCF service and we are not able to acheive that. We are calling the WCF service (located on a server) with a WPF app. We tryied to create custom Class into the CodeTrigger Business Layer, but we are not able to see it thru the service. Can you help us on that? Thanks
04/12/2017
Topic:
Using CriteriaApi queries across the WCF boundary

migrator
migrator
Administrator
Hi
CriteriaApi does not work across the WCF boundary. In this case ordinary search is implemented using the less powerful 'SearchObjects' mechanism.
You can however have your own custom method on the WCF interface which is implemented in the server side with CriteriaApi
04/12/2017
Topic:
Asp.Net identity optional in the Mvc/WebApi wizard

migrator
migrator
Administrator
First allow me to echo I have found CodeTrigger to be one of the most carefully constructed, deliberate and useful tools available in the domain of code generation. If there is one "limitation" of the product I have found thus far is the requirement to use .Net Membership while generating the MVC/API example. While not difficult, removing the code adds to development time to the point where it is more cost effective to not use your tool. One custom modification I would request is to add some process step to disable generation of such code.
04/12/2017
Topic:
Asp.Net identity optional in the Mvc/WebApi wizard

migrator
migrator
Administrator
Hi
I thought id let you know that use of asp.net identity for authentication in the MVC wizard is now optional, as per feature request discussed above.
This is part of the latest CodeTrigger update that shipped last night. (4.9.2.1)
04/12/2017
Topic:
Autofac, 3rd party logging

migrator
migrator
Administrator
One of my clients has mandated the use of AutoFac, log4Net and Moq. Your tool accomplishes 70% of all the coding we require. [What to do about the rest]..


I am aware of how much your tool generates in this regard; I am just seeking the remainder to eliminate one area of development needs. Essentially, I am looking to amend your tool to function better at the data persistence layer in our environment. I am not sure how many of your clients fall into our category but your tool is not far from being an absolutely perfect code generation tool for my firm.
04/12/2017
Topic:
Autofac, 3rd party logging

migrator
migrator
Administrator
Looking at the sample, you would only need to edit 2 or 3 base classes or so to add your custom log4net handling code into the empty methods that have already been provided.




Regarding Autofac, this is somewhat more problematic as i dont immediately see the value, it seems to go against the grain of CodeTrigger, which is more or less a replacement so you dont need Autofac...
04/12/2017
Topic:
PostgreSQL Support

migrator
migrator
Administrator
Thank you for creating such a marvelous product. My question how can I get codetrigger to create database classes for PostgreSQL database. I know it supports MySQL, but I want to use it with PostgreSQL for a project.
04/12/2017
Topic:
PostgreSQL Support

migrator
migrator
Administrator
Hi, CodeTrigger does not support PostgreSQL at this time