Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Never Let A Opportunity Go to Waste

Never Let A Opportunity Go to Waste

Scheduled Pinned Locked Moved The Lounge
databasecsharpcsssql-serverlinq
19 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R RickZeeland

    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 :-\

    realJSOPR Offline
    realJSOPR Offline
    realJSOP
    wrote on last edited by
    #5

    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 and IDataErrorinfo (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

    1 Reply Last reply
    0
    • realJSOPR realJSOP

      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
      
      honey the codewitchH Offline
      honey the codewitchH Offline
      honey the codewitch
      wrote on last edited by
      #6

      I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.

      Real programmers use butterflies

      R Sander RosselS realJSOPR M 4 Replies Last reply
      0
      • realJSOPR realJSOP

        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
        
        A Offline
        A Offline
        Amarnath S
        wrote on last edited by
        #7

        Why not an article, or even a tip, where it stays in a more permanent place than this Lounge?

        realJSOPR 1 Reply Last reply
        0
        • honey the codewitchH honey the codewitch

          I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.

          Real programmers use butterflies

          R Offline
          R Offline
          RickZeeland
          wrote on last edited by
          #8

          Be careful what you say about JSOP, he's very dangerous :-\

          1 Reply Last reply
          0
          • A Amarnath S

            Why not an article, or even a tip, where it stays in a more permanent place than this Lounge?

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #9
            1. 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

            1 Reply Last reply
            0
            • honey the codewitchH honey the codewitch

              I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.

              Real programmers use butterflies

              Sander RosselS Offline
              Sander RosselS Offline
              Sander Rossel
              wrote on last edited by
              #10

              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

              1 Reply Last reply
              0
              • realJSOPR realJSOP

                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
                
                Sander RosselS Offline
                Sander RosselS Offline
                Sander Rossel
                wrote on last edited by
                #11

                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

                realJSOPR 1 Reply Last reply
                0
                • honey the codewitchH honey the codewitch

                  I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.

                  Real programmers use butterflies

                  realJSOPR Offline
                  realJSOPR Offline
                  realJSOP
                  wrote on last edited by
                  #12

                  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

                  honey the codewitchH 1 Reply Last reply
                  0
                  • realJSOPR realJSOP

                    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

                    honey the codewitchH Offline
                    honey the codewitchH Offline
                    honey the codewitch
                    wrote on last edited by
                    #13

                    I don't either, personally. I appreciated your comment, as I am a fan of code generation.

                    Real programmers use butterflies

                    1 Reply Last reply
                    0
                    • Sander RosselS Sander Rossel

                      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

                      realJSOPR Offline
                      realJSOPR Offline
                      realJSOP
                      wrote on last edited by
                      #14

                      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 an Upsert 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 for INotifyPropertyChanged, and IDataErrrorInfo interfaces in the generated viewmodel, and you can even specify the standard using 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 RosselS 1 Reply Last reply
                      0
                      • realJSOPR realJSOP

                        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 an Upsert 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 for INotifyPropertyChanged, and IDataErrrorInfo interfaces in the generated viewmodel, and you can even specify the standard using 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 RosselS Offline
                        Sander RosselS Offline
                        Sander Rossel
                        wrote on last edited by
                        #15

                        #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

                        1 Reply Last reply
                        0
                        • honey the codewitchH honey the codewitch

                          I think I would get flayed if I posted that much code in the lounge. :laugh: Congratulations to you.

                          Real programmers use butterflies

                          M Offline
                          M Offline
                          Mycroft Holmes
                          wrote on last edited by
                          #16

                          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

                          honey the codewitchH 1 Reply Last reply
                          0
                          • M Mycroft Holmes

                            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

                            honey the codewitchH Offline
                            honey the codewitchH Offline
                            honey the codewitch
                            wrote on last edited by
                            #17

                            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

                            1 Reply Last reply
                            0
                            • realJSOPR realJSOP

                              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
                              
                              K Offline
                              K Offline
                              Kelly Herald
                              wrote on last edited by
                              #18

                              The company I work for would flog you for using the NOLOCK hint in your SELECT statement. :)

                              Kelly Herald Software Developer

                              realJSOPR 1 Reply Last reply
                              0
                              • K Kelly Herald

                                The company I work for would flog you for using the NOLOCK hint in your SELECT statement. :)

                                Kelly Herald Software Developer

                                realJSOPR Offline
                                realJSOPR Offline
                                realJSOP
                                wrote on last edited by
                                #19

                                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

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups