Never Let A Opportunity Go to Waste
-
Quote:
support your own kind of chaos
I already have enough chaos at hands thank you! Should really try harder to work with NHibernate as that's what has been chosen as the standard where I work, but till now have been able to avoid implementing it in the projects I work on. Also I should do some DevOppy things with Docker, but it seems to make no sense to use Docker with Windows, it's clearly a Linux thing :-\
Thankfully, nobody on our team is enamoured with ORMs of any description. I can really understand the desire to have some of your more tedious code auto-magically generated, but ORMs impose to many proprietary ideas about how things should work, and how you should work with them, and it's often more tedious to find out how to get around those ideas than it is just to crank out your own code. This tool leans more towards the "crank out your own code" crowd. Even the viewmodel generator allows you to specify your own implementation of
INotifyPropertyChanged
andIDataErrorinfo
(it provides my own implementation as a default, but the user can change it).".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
I found myself with nothing to do this week, so I decided to make a concerted effort to repair the significant code loss I suffered back in May/2020 with respect to my entity factory app. I think I'm happy once again with the model generation, so I figured I'd post some code the app generated for me. For those that have forgotten, EntityFactory will generate model (and optionally viewmodel) classes based on the selected table, view, and stored procedure (SQL server). What makes this app more functional than the ADO code generator is that it will generate an object for any stored proc that returns data, regardless of the method by which the data is returned (the ADO code generator refuses to work with stored procs that return data with dynamic sql, and re-generating code doesn't work in a number of spectacular ways). In the sample below, I turned on the generation of crud properties, just to exercise that part of the code. All of the code below was generated based on the returned schema for the indicated database source object. Processing took less than a second.
/==================================================================================================
// Source object: AEF2.dbo.Alerts (table)
// File generated: 2020.11.27, 01:03:07// This file was generated by EntityFactory. Do not modify this file. When regenerated, the file
// may be overwritten if it already exists (and EntityFactory was configured to overwrite existing
// files). Note that the generated class is "partial", so if you need to augment the generated
// code, create a new partial extension file and put your custom code in that new file.// The class name indicates the model (or viewmodel) class name prefix followed by the name of the
// original database object from which the class was generated.
//==================================================================================================using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;// Auto-incrementing column detected - added the following using to support standard C# attributes.
// If you haven't already, add a reference to System.ComponentModel.DataAnnotations to the
// applicable assembly in your application.
using System.ComponentModel.DataAnnotations;namespace Models
{
public partial class EntityAlerts
{
#region entity properties\[Key\] public int
I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.
Real programmers use butterflies
-
I found myself with nothing to do this week, so I decided to make a concerted effort to repair the significant code loss I suffered back in May/2020 with respect to my entity factory app. I think I'm happy once again with the model generation, so I figured I'd post some code the app generated for me. For those that have forgotten, EntityFactory will generate model (and optionally viewmodel) classes based on the selected table, view, and stored procedure (SQL server). What makes this app more functional than the ADO code generator is that it will generate an object for any stored proc that returns data, regardless of the method by which the data is returned (the ADO code generator refuses to work with stored procs that return data with dynamic sql, and re-generating code doesn't work in a number of spectacular ways). In the sample below, I turned on the generation of crud properties, just to exercise that part of the code. All of the code below was generated based on the returned schema for the indicated database source object. Processing took less than a second.
/==================================================================================================
// Source object: AEF2.dbo.Alerts (table)
// File generated: 2020.11.27, 01:03:07// This file was generated by EntityFactory. Do not modify this file. When regenerated, the file
// may be overwritten if it already exists (and EntityFactory was configured to overwrite existing
// files). Note that the generated class is "partial", so if you need to augment the generated
// code, create a new partial extension file and put your custom code in that new file.// The class name indicates the model (or viewmodel) class name prefix followed by the name of the
// original database object from which the class was generated.
//==================================================================================================using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;// Auto-incrementing column detected - added the following using to support standard C# attributes.
// If you haven't already, add a reference to System.ComponentModel.DataAnnotations to the
// applicable assembly in your application.
using System.ComponentModel.DataAnnotations;namespace Models
{
public partial class EntityAlerts
{
#region entity properties\[Key\] public int
Why not an article, or even a tip, where it stays in a more permanent place than this Lounge?
-
I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.
Real programmers use butterflies
Be careful what you say about JSOP, he's very dangerous :-\
-
Why not an article, or even a tip, where it stays in a more permanent place than this Lounge?
- I've been here for 20 years. I know how to do this. 1) I'll write/publish the article when the code is done. I started the article last May when the code was reasonably complete, but lost a crap load of the code, and stopped working on it. As stated in the original message, I decided to start working on it again this week to rewrite the code I'd lost, and was merely sharing the progress. 2) Cool your jets, Sparky.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.
Real programmers use butterflies
In American Texas, code poster flays you :D
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
-
I found myself with nothing to do this week, so I decided to make a concerted effort to repair the significant code loss I suffered back in May/2020 with respect to my entity factory app. I think I'm happy once again with the model generation, so I figured I'd post some code the app generated for me. For those that have forgotten, EntityFactory will generate model (and optionally viewmodel) classes based on the selected table, view, and stored procedure (SQL server). What makes this app more functional than the ADO code generator is that it will generate an object for any stored proc that returns data, regardless of the method by which the data is returned (the ADO code generator refuses to work with stored procs that return data with dynamic sql, and re-generating code doesn't work in a number of spectacular ways). In the sample below, I turned on the generation of crud properties, just to exercise that part of the code. All of the code below was generated based on the returned schema for the indicated database source object. Processing took less than a second.
/==================================================================================================
// Source object: AEF2.dbo.Alerts (table)
// File generated: 2020.11.27, 01:03:07// This file was generated by EntityFactory. Do not modify this file. When regenerated, the file
// may be overwritten if it already exists (and EntityFactory was configured to overwrite existing
// files). Note that the generated class is "partial", so if you need to augment the generated
// code, create a new partial extension file and put your custom code in that new file.// The class name indicates the model (or viewmodel) class name prefix followed by the name of the
// original database object from which the class was generated.
//==================================================================================================using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;// Auto-incrementing column detected - added the following using to support standard C# attributes.
// If you haven't already, add a reference to System.ComponentModel.DataAnnotations to the
// applicable assembly in your application.
using System.ComponentModel.DataAnnotations;namespace Models
{
public partial class EntityAlerts
{
#region entity properties\[Key\] public int
CrudGet* CrudUpsert* CrudDelete* :D I was going to ask why you didn't use a MERGE for the UPSERT, but I already found out myself. Good stuff! :thumbsup:
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
-
I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.
Real programmers use butterflies
I don't see the problem with posting the output from a code generator, as long as you don't pose a question about it in the message. At that point, you're simply showing the output of an application. If anyone gives you grief, let me know - I'll set 'em straight. Note - I purposely chose a table that only has a few returned columns.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
I don't see the problem with posting the output from a code generator, as long as you don't pose a question about it in the message. At that point, you're simply showing the output of an application. If anyone gives you grief, let me know - I'll set 'em straight. Note - I purposely chose a table that only has a few returned columns.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013I don't either, personally. I appreciated your comment, as I am a fan of code generation.
Real programmers use butterflies
-
CrudGet* CrudUpsert* CrudDelete* :D I was going to ask why you didn't use a MERGE for the UPSERT, but I already found out myself. Good stuff! :thumbsup:
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
Sander Rossel wrote:
I was going to ask why you didn't use a MERGE for the UPSERT, but I already found out myself.
Using the
MERGE
function is fraught with danger, and it's easy to do it wrong. Furthermore, a MERGE operation is usually more complex, and typically uses several of the table's columns to determine whether or not an item should be updated. There's probably no way to generate it automagically that would be suitable in more than a small handful of instances. It is simply easier and more reliable to generate anUpsert
instead. The programmer can always extend the generated partial class and include a specific CRUDMerge property, so I think my bases are sufficiently covered. BTW, this is primary reason I'm writing this aapp - the existing tools don't create partial classes, and don't allow you to customize their implementation based on corporate requirements as far as coding style and framework component inclusion. For instance, you can specify your own implementation code forINotifyPropertyChanged,
andIDataErrrorInfo
interfaces in the generated viewmodel, and you can even specify the standardusing
statements for the model and viewmodel (although the usefulness of these would only benefit you if a given "standard" name space was removed from .Net at some point in the future). It's a cool app, and we're going to use it at work when we start our flagship application rewrite (whenever that's allowed to happen).".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Sander Rossel wrote:
I was going to ask why you didn't use a MERGE for the UPSERT, but I already found out myself.
Using the
MERGE
function is fraught with danger, and it's easy to do it wrong. Furthermore, a MERGE operation is usually more complex, and typically uses several of the table's columns to determine whether or not an item should be updated. There's probably no way to generate it automagically that would be suitable in more than a small handful of instances. It is simply easier and more reliable to generate anUpsert
instead. The programmer can always extend the generated partial class and include a specific CRUDMerge property, so I think my bases are sufficiently covered. BTW, this is primary reason I'm writing this aapp - the existing tools don't create partial classes, and don't allow you to customize their implementation based on corporate requirements as far as coding style and framework component inclusion. For instance, you can specify your own implementation code forINotifyPropertyChanged,
andIDataErrrorInfo
interfaces in the generated viewmodel, and you can even specify the standardusing
statements for the model and viewmodel (although the usefulness of these would only benefit you if a given "standard" name space was removed from .Net at some point in the future). It's a cool app, and we're going to use it at work when we start our flagship application rewrite (whenever that's allowed to happen).".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013#realJSOP wrote:
It's a cool app, and we're going to use it at work when we start our flagship application rewrite (whenever that's allowed to happen).
Good stuff! I've been using Entity Framework Core and love it so far. I just write my domain models, write my DB mapping and let EF sort out the rest. Not so nice when you get breaking changes and EF just drops a column (or table) instead of renaming and that sort of stuff :laugh: The queries it generates are pretty clean overall and I've gotten a lot better at predicating what they look like based on my LINQ query :)
Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
-
I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.
Real programmers use butterflies
JSOP is a special case, a bit like OG, the Richards and you for that matter. People who contribute so much to the site that they have and deserve carte blanche. It is very rarely abused.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
-
JSOP is a special case, a bit like OG, the Richards and you for that matter. People who contribute so much to the site that they have and deserve carte blanche. It is very rarely abused.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
That's fair. I try not to abuse the forum myself but I'm a weirdo and social decorum is not always my best strength, even online. Even among other developers. :laugh:
Real programmers use butterflies
-
I found myself with nothing to do this week, so I decided to make a concerted effort to repair the significant code loss I suffered back in May/2020 with respect to my entity factory app. I think I'm happy once again with the model generation, so I figured I'd post some code the app generated for me. For those that have forgotten, EntityFactory will generate model (and optionally viewmodel) classes based on the selected table, view, and stored procedure (SQL server). What makes this app more functional than the ADO code generator is that it will generate an object for any stored proc that returns data, regardless of the method by which the data is returned (the ADO code generator refuses to work with stored procs that return data with dynamic sql, and re-generating code doesn't work in a number of spectacular ways). In the sample below, I turned on the generation of crud properties, just to exercise that part of the code. All of the code below was generated based on the returned schema for the indicated database source object. Processing took less than a second.
/==================================================================================================
// Source object: AEF2.dbo.Alerts (table)
// File generated: 2020.11.27, 01:03:07// This file was generated by EntityFactory. Do not modify this file. When regenerated, the file
// may be overwritten if it already exists (and EntityFactory was configured to overwrite existing
// files). Note that the generated class is "partial", so if you need to augment the generated
// code, create a new partial extension file and put your custom code in that new file.// The class name indicates the model (or viewmodel) class name prefix followed by the name of the
// original database object from which the class was generated.
//==================================================================================================using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;// Auto-incrementing column detected - added the following using to support standard C# attributes.
// If you haven't already, add a reference to System.ComponentModel.DataAnnotations to the
// applicable assembly in your application.
using System.ComponentModel.DataAnnotations;namespace Models
{
public partial class EntityAlerts
{
#region entity properties\[Key\] public int
The company I work for would flog you for using the
NOLOCK
hint in your SELECT statement. :)Kelly Herald Software Developer
-
The company I work for would flog you for using the
NOLOCK
hint in your SELECT statement. :)Kelly Herald Software Developer
Wehave simulateous access by thousands of users and dozens of stored procs, we have to do that because our queries take a few seconds.If we don't do it, we get errors.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013