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. Linq + SQLMetal = Cool...

Linq + SQLMetal = Cool...

Scheduled Pinned Locked Moved The Lounge
csharpdatabasevisual-studiosql-serverlinq
56 Posts 24 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.
  • L Luc Pattyn

    Another "Aaaaarrgggh! I spoke too soon" then? :doh:

    Luc Pattyn [Forum Guidelines] [My Articles]


    - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


    H Offline
    H Offline
    Henry Minute
    wrote on last edited by
    #22

    Oh yes! And it probably won't be the last. The filter between my brain and mouth/fingers got broken a long time ago.

    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

    1 Reply Last reply
    0
    • C code frog 0

      So here I am totally bogged down in reluctance to write more data access code and stored procedures. I hate it. It's tedious and bothersome. So... I google C# code generation SQL server and out pops this Linq result that talks about SQLMetal. Not having a clue at all what I'm looking at I bite. I open up the VS 2008 command prompt and type in:

      C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>sqlmetal /server:{server} /database:{db} /namespace:{new namespace} /code:{ClassName}.cs /language:csharp

      I hit enter and think this won't work. What do you know... Out pops a huge monolithic class that has all of the stuff required to Create/Insert/Update/Delete every table in the DB all VIA Linq. {Scratches Head} How the heck do I use this? Turns out a quick Google search and *BOOM* it's out of the park. No inline SQL, no stored procedures and no boredom. It's all done. I just invoke the class, instance my table populate the fields and then it's time to "Smile and Waive" as I call Submit(). I'm now a Linq convert. I will never go back. :cool:

      M Offline
      M Offline
      Member 96
      wrote on last edited by
      #23

      Allow me to retort: Every application that was built with an ORM code generator off a database (and no huge amount of hand tweaking) has a crappy UI that should be taken out and shot, not inflicted on an unsuspecting public. Code Generation without heavy tweaking = crappy software, it's axiomatic. The correct and necessary way to store data in a database and the tasks that the end users need to accomplish are 180 degrees apart and the business objects in a well crafted easy to use application bear little resemblance to the database schema. Our whole job as developers is not just to develop software, it's to abstract away the inner workings of computers and software and present the end user with something that looks and works how they think. If you start below the UI with business objects that are a perfect reflection of the database then you are led down a path that ends with crazy forms with rank upon rank of what are basically database fields exposed directly in the UI and a bunch of pointless extra work and confusion for the end user. People don't need developers for that, they can just hire a sql admin to make a database and users can just enter in the data in the tables directly. The point of being a developer is to be a crafstman who uses a combination of skill, and artistic ability to make the connection between the reality of the end users tasks they need to accomplish throughout their day and the separate reality of how data should be stored in a database. If you say you're using code generation for the heavy lifting then going back and heavily re-tweaking it for anything of consequence then that's fine but if you're generating the code then going on to the interface you're building a foundation on quicksand. And if you really are planning on hand tweaking LINQ has to be about the worst abomination to inflict upon yourself to no useful purpose I can imagine. Dense, unreadable, unmaintainable.... X|


      "It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson

      C P 2 Replies Last reply
      0
      • C code frog 0

        So here I am totally bogged down in reluctance to write more data access code and stored procedures. I hate it. It's tedious and bothersome. So... I google C# code generation SQL server and out pops this Linq result that talks about SQLMetal. Not having a clue at all what I'm looking at I bite. I open up the VS 2008 command prompt and type in:

        C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>sqlmetal /server:{server} /database:{db} /namespace:{new namespace} /code:{ClassName}.cs /language:csharp

        I hit enter and think this won't work. What do you know... Out pops a huge monolithic class that has all of the stuff required to Create/Insert/Update/Delete every table in the DB all VIA Linq. {Scratches Head} How the heck do I use this? Turns out a quick Google search and *BOOM* it's out of the park. No inline SQL, no stored procedures and no boredom. It's all done. I just invoke the class, instance my table populate the fields and then it's time to "Smile and Waive" as I call Submit(). I'm now a Linq convert. I will never go back. :cool:

        A Offline
        A Offline
        Ashley van Gerven
        wrote on last edited by
        #24

        Just bear in mind that Linq 2 SQL is not being heavily improved or maintained by Microsoft. Their focus is on Entity Framework (many similarities, but more capabilities). A major gripe of mine with Linq 2 SQL is that you cannot update a single table from the DB (using sqlmetal or VS). You have to regenerate the entire class (i.e. all tables).

        "For fifty bucks I'd put my face in their soup and blow." - George Costanza

        CP article: SmartPager - a Flickr-style pager control with go-to-page popup layer.

        R 1 Reply Last reply
        0
        • M Member 96

          Allow me to retort: Every application that was built with an ORM code generator off a database (and no huge amount of hand tweaking) has a crappy UI that should be taken out and shot, not inflicted on an unsuspecting public. Code Generation without heavy tweaking = crappy software, it's axiomatic. The correct and necessary way to store data in a database and the tasks that the end users need to accomplish are 180 degrees apart and the business objects in a well crafted easy to use application bear little resemblance to the database schema. Our whole job as developers is not just to develop software, it's to abstract away the inner workings of computers and software and present the end user with something that looks and works how they think. If you start below the UI with business objects that are a perfect reflection of the database then you are led down a path that ends with crazy forms with rank upon rank of what are basically database fields exposed directly in the UI and a bunch of pointless extra work and confusion for the end user. People don't need developers for that, they can just hire a sql admin to make a database and users can just enter in the data in the tables directly. The point of being a developer is to be a crafstman who uses a combination of skill, and artistic ability to make the connection between the reality of the end users tasks they need to accomplish throughout their day and the separate reality of how data should be stored in a database. If you say you're using code generation for the heavy lifting then going back and heavily re-tweaking it for anything of consequence then that's fine but if you're generating the code then going on to the interface you're building a foundation on quicksand. And if you really are planning on hand tweaking LINQ has to be about the worst abomination to inflict upon yourself to no useful purpose I can imagine. Dense, unreadable, unmaintainable.... X|


          "It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson

          C Offline
          C Offline
          code frog 0
          wrote on last edited by
          #25

          I don't think you've seen the generated code at all. Look at it and then come back and post. Until then my comments stand.

          M 1 Reply Last reply
          0
          • C code frog 0

            I don't think you've seen the generated code at all. Look at it and then come back and post. Until then my comments stand.

            M Offline
            M Offline
            Member 96
            wrote on last edited by
            #26

            :) Rex, you somehow missed the entire point of my post. I don't need to see the generated code, it's not about that at all, all I need to know is that you generated it from a database directly. It's like cocaine, it might seem good at first in small amounts but it will quickly destroy the end result while giving the impression of doing very well.


            "It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson

            C 1 Reply Last reply
            0
            • M Mycroft Holmes

              Now I thought every developer who builds DB centric apps has built one of these, I am always astounded by the comercial code generators that actually survive. The one I use was first built in the mid 90's has been rewritten unmpteen times and does precicely what I want it to do, which is about 85-90% of the SQL code, including the stored procs. How do you guys survive not knowing whats under the hood?

              Never underestimate the power of human stupidity RAH

              C Offline
              C Offline
              code frog 0
              wrote on last edited by
              #27

              The person to whom I'm replying thinks I'm being a bit rude below. In retrospect I think he's right. Still once in a while it's fun to scrap a little so I'll just leave this all intact. I did apologize to him a bit further in. So smile a bit and relax. Nobody got hurt especially the little farm animals. :-D ? You aren't making sense. What's under the hood? It generates some very simple code. You look at it. You decide whether it meets your needs or it doesn't. Is it code you could write on your own? Yes. There is no hood. I'm not sure I follow your comment at all. But it kind of seems to me like you are the guy that codes in notepad, injects assembler and takes a year to write an application the rest of us wrote in a week. Yes I could do it all in bare bones C. But I evolved and learned to do it C++. Once I got to where I could do it all in C++ I had to evolve again and learn how to do it in C#. Now I'm self-employed. I've got a wife, kids and a dog. I don't need to prove to the world that I'm some coding bad ass that can sort 9000 teraflops in 30 milliseconds. Doesn't even get a rise out of me. I want a good solution to a reasonable problem that meets the need with minimal fuss. Then I want to go home. Hug the kids. Kiss the wife and have dinner. When I think what's under the hood it usually involves whatever my wife is wearing. But when it comes to code I've got enough self-confidence where I don't have to worry too much about inventing the wheel every single day just to grow another chest hair. I find a wheel, it's round, it fits, hey it even matches the other wheel. Great! I'm gone. Have fun with notepad. Lemme guess... cobal right? Okay. Take care. I'm going to hug my wife and kids now. Catch you later.

              M 1 Reply Last reply
              0
              • M Member 96

                :) Rex, you somehow missed the entire point of my post. I don't need to see the generated code, it's not about that at all, all I need to know is that you generated it from a database directly. It's like cocaine, it might seem good at first in small amounts but it will quickly destroy the end result while giving the impression of doing very well.


                "It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson

                C Offline
                C Offline
                code frog 0
                wrote on last edited by
                #28

                I'm in a scrappy mood. I'm mostly serious about what I'm saying but I'm also having some fun too. Keep that in mind. :-\ Oh. Okay. Well you better quit using .Net because in case you haven't noticed... it's generated code written by the same guys. I'm not Elvis but I am letting this one go. Just doesn't mean that much to me at all. By the way I didn't vote you down either. I don't vote at all unless it's a 5. I never low vote. Anyway, if that's your battle cry head to war. I'll watch from the distance while I eat with my family and relax. The thing that kills me is you have zero clue how I'm using the code. God no I'm not parking a UI right on top of it. The UI hasn't even been written yet. The only thing I'm using it for is a data layer and that's it. I just wanted a simple class I could invoke to save to the DB. I'm so far away from building a UI it's not even funny. Yet you seem to assume that somehow I bound controls to the generated class and called it an application. Sorry. Haven't done that since... uh well I've uh never done that. Your whole tone is condescending like you are some all knowing wise man sitting on top of your golden mountain populated with coffee beans that you fart out of nothing. You don't have a clue what I'm doing. How I'm doing it or anything else. You start off about things like cocaine and sand and it makes no sense at all. Try asking more questions. Try actually understanding what a person is doing. Make sure you fully grasp what it is they are attempting and how it is they are attempting it. At that point make a suggestion but please don't pass judgment like some arcane ruler that sits on a cloud. It's annoying.

                M 1 Reply Last reply
                0
                • C code frog 0

                  The person to whom I'm replying thinks I'm being a bit rude below. In retrospect I think he's right. Still once in a while it's fun to scrap a little so I'll just leave this all intact. I did apologize to him a bit further in. So smile a bit and relax. Nobody got hurt especially the little farm animals. :-D ? You aren't making sense. What's under the hood? It generates some very simple code. You look at it. You decide whether it meets your needs or it doesn't. Is it code you could write on your own? Yes. There is no hood. I'm not sure I follow your comment at all. But it kind of seems to me like you are the guy that codes in notepad, injects assembler and takes a year to write an application the rest of us wrote in a week. Yes I could do it all in bare bones C. But I evolved and learned to do it C++. Once I got to where I could do it all in C++ I had to evolve again and learn how to do it in C#. Now I'm self-employed. I've got a wife, kids and a dog. I don't need to prove to the world that I'm some coding bad ass that can sort 9000 teraflops in 30 milliseconds. Doesn't even get a rise out of me. I want a good solution to a reasonable problem that meets the need with minimal fuss. Then I want to go home. Hug the kids. Kiss the wife and have dinner. When I think what's under the hood it usually involves whatever my wife is wearing. But when it comes to code I've got enough self-confidence where I don't have to worry too much about inventing the wheel every single day just to grow another chest hair. I find a wheel, it's round, it fits, hey it even matches the other wheel. Great! I'm gone. Have fun with notepad. Lemme guess... cobal right? Okay. Take care. I'm going to hug my wife and kids now. Catch you later.

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

                  Hmm wrong handle on what I meant. I need to know why and how it generated the code so I use a script generator that I wrote, I understand it, I control the output and can change the output to meet my needs which change over time (went from VB 5 to 6 to VB.net to C#).

                  code-frog wrote:

                  But it kind of seems to me like you are the guy that codes in notepad

                  Now you are just being rude. One of the reasons I am successful is that I can produce LOB solutions rapidly.

                  code-frog wrote:

                  I find a wheel, it's round, it fits, hey it even matches the other wheel

                  I would rather build the wheel, quite happy for someone else to invent it and why would you rebuild a wheel everyday. Enjoy your time with the kids and wife, better than coding anytime.....

                  Never underestimate the power of human stupidity RAH

                  C 1 Reply Last reply
                  0
                  • M Mycroft Holmes

                    Hmm wrong handle on what I meant. I need to know why and how it generated the code so I use a script generator that I wrote, I understand it, I control the output and can change the output to meet my needs which change over time (went from VB 5 to 6 to VB.net to C#).

                    code-frog wrote:

                    But it kind of seems to me like you are the guy that codes in notepad

                    Now you are just being rude. One of the reasons I am successful is that I can produce LOB solutions rapidly.

                    code-frog wrote:

                    I find a wheel, it's round, it fits, hey it even matches the other wheel

                    I would rather build the wheel, quite happy for someone else to invent it and why would you rebuild a wheel everyday. Enjoy your time with the kids and wife, better than coding anytime.....

                    Never underestimate the power of human stupidity RAH

                    C Offline
                    C Offline
                    code frog 0
                    wrote on last edited by
                    #30

                    If I misunderstood I completely apologize. But there seems to be a belief here that I'm wizarding out an entire application. I'm not at all. In fact I'm just writing some stuff from a cookie into a database. It's small, simple and really not rocket science in the least. Everyone seems to think that because someone shares a cool thing they intend to use it for everything. Simply that's not the case. It's a nifty thing for isolated situations where you don't need super fine control of the situation. That's all. But my apologies for being rude. I think you are right.

                    M 1 Reply Last reply
                    0
                    • C code frog 0

                      If I misunderstood I completely apologize. But there seems to be a belief here that I'm wizarding out an entire application. I'm not at all. In fact I'm just writing some stuff from a cookie into a database. It's small, simple and really not rocket science in the least. Everyone seems to think that because someone shares a cool thing they intend to use it for everything. Simply that's not the case. It's a nifty thing for isolated situations where you don't need super fine control of the situation. That's all. But my apologies for being rude. I think you are right.

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

                      Not a problem - I thought we may have been starting a flame war, damm I haven't been in one of them in ages :laugh: The only reason I have not turned my code gen into an article is that there are soooo many already out there. I think code gen and databases are the only areas where I would not look into new/different tools. Some of the stuff you see come through here is fascinating - others are crap of course.

                      Never underestimate the power of human stupidity RAH

                      1 Reply Last reply
                      0
                      • A Ashley van Gerven

                        Just bear in mind that Linq 2 SQL is not being heavily improved or maintained by Microsoft. Their focus is on Entity Framework (many similarities, but more capabilities). A major gripe of mine with Linq 2 SQL is that you cannot update a single table from the DB (using sqlmetal or VS). You have to regenerate the entire class (i.e. all tables).

                        "For fifty bucks I'd put my face in their soup and blow." - George Costanza

                        CP article: SmartPager - a Flickr-style pager control with go-to-page popup layer.

                        R Offline
                        R Offline
                        Rocky Moore
                        wrote on last edited by
                        #32

                        Ashley van Gerven wrote:

                        A major gripe of mine with Linq 2 SQL is that you cannot update a single table from the DB (using sqlmetal or VS). You have to regenerate the entire class (i.e. all tables).

                        How is it you have to regenerate classes for all tables within VS? When you select a LINQ 2 SQL class, it will bring up the designer on which you can place a single table in a class. Perhaps you are referring to updating a table without generating any class?

                        Rocky <>< Recent Blog Post: ViewState and SEO – Move it! Thinking about Silverlight? www.SilverlightCity.com

                        A 1 Reply Last reply
                        0
                        • R Rocky Moore

                          You do not have to go to SQLMetal, just add an LINQ to SQL Class to your project (you can have multiples too) and it will open up the designer. Switch to Server Explorer (View/Server Explorer), connect to the database and drag the tables you want onto the design surface. You can add relationships as you will and rename the objects it creates if you have a need. You can also drag a stored procedure over the the design seruver and it will create a method in the object class to call it with its parameters. Slick stuff! The classes it generates are all partial class types so you can add a new file to your project and extended those object classes such as display translations, business logic, etc. Really handy! Of course, this is just LINQ to SQL, LINQ itself works great for other objects and XML. It is a great general data query langauge that spans all data that are objects regardless of where you get the data. One word of caution though, in the beginning you need to watch carefully what is being sent to the server and when. With its lazy loading of objects, a simple query and walking through the data can generate hundreds, thousands or even tens of thousands of queries without you noticing. You have to take control on what is loaded and when. This is a step you already have to take care of manually in the old methods of data access, and for some new to LINQ to SQL, they think all that is automatic as they do not see it. We still have that responsiblity even though we do not notice it at first.

                          Rocky <>< Recent Blog Post: ViewState and SEO – Move it! Thinking about Silverlight? www.SilverlightCity.com

                          O Offline
                          O Offline
                          oooshola
                          wrote on last edited by
                          #33

                          You may want to look into using the Entity Framework and Linq to Entities before investing time and energy to Linq to Sql. Microsoft basically said that they're not going to invest more energy in advancing it, and the Entity Framework should be what we use instead. Fortunately, the EF can be dragged and dropped VERY similar to how Rocky explained Linq to Sql works. http://blogs.msdn.com/adonet/archive/2008/10/29/update-on-linq-to-sql-and-linq-to-entities-roadmap.aspx[^]

                          www.flixgadget.com

                          S 1 Reply Last reply
                          0
                          • C code frog 0

                            So here I am totally bogged down in reluctance to write more data access code and stored procedures. I hate it. It's tedious and bothersome. So... I google C# code generation SQL server and out pops this Linq result that talks about SQLMetal. Not having a clue at all what I'm looking at I bite. I open up the VS 2008 command prompt and type in:

                            C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>sqlmetal /server:{server} /database:{db} /namespace:{new namespace} /code:{ClassName}.cs /language:csharp

                            I hit enter and think this won't work. What do you know... Out pops a huge monolithic class that has all of the stuff required to Create/Insert/Update/Delete every table in the DB all VIA Linq. {Scratches Head} How the heck do I use this? Turns out a quick Google search and *BOOM* it's out of the park. No inline SQL, no stored procedures and no boredom. It's all done. I just invoke the class, instance my table populate the fields and then it's time to "Smile and Waive" as I call Submit(). I'm now a Linq convert. I will never go back. :cool:

                            D Offline
                            D Offline
                            dbullen
                            wrote on last edited by
                            #34

                            Hi I agree it's all cool, but i thought Linq to SQL was getting binned/de-supported/ignored? In favour of Entity Framework? Am I wrong? If nto, is it worth the investment? Dean

                            C 1 Reply Last reply
                            0
                            • O oooshola

                              You may want to look into using the Entity Framework and Linq to Entities before investing time and energy to Linq to Sql. Microsoft basically said that they're not going to invest more energy in advancing it, and the Entity Framework should be what we use instead. Fortunately, the EF can be dragged and dropped VERY similar to how Rocky explained Linq to Sql works. http://blogs.msdn.com/adonet/archive/2008/10/29/update-on-linq-to-sql-and-linq-to-entities-roadmap.aspx[^]

                              www.flixgadget.com

                              S Offline
                              S Offline
                              SimonRigby
                              wrote on last edited by
                              #35

                              Yup, Was truly excellent news to hear about that exactly 2 days after I had ported our flagship application to LINQ to SQL. Thanks for that . However, that being said, I am quietly porting the app yet again to the Entity Framework and its not been too painful. Some methods that I used from LINQ to SQL (mainly SingleOrDefault) don't exist in EF so I have had to make some changes, but I'd say 80% of the code has ported unchaged. The majority has really been creating the EF equivelant of the dbml file and swapping out the creation code for creating the DataContext. I'm just glad I chose to access the data through an intermediary layer so none of the client code has been affected. As far as the OP is concerned (a question for those who are familiar with the designer approach), is this SqlMetal command line tool effectively a command line version of the designer or is there extra goodness I'd want to know about? Cheers

                              The only thing unpredictable about me is just how predictable I'm going to be.

                              O 1 Reply Last reply
                              0
                              • C code frog 0

                                I didn't keep all the generated code. I went in and cut out all the stuff I won't use. I paired about 60% of the mass out of the class. Now it's tight and lean and I've seen all the code too. Just because it hands you a blimp doesn't mean you have to keep it that way. As the documentation suggests it's meant to be a base that you then customize or extend to meet your own needs. Regardless... !SOLD!:rose: {Edit}:thumbsup: Honestly, you should check it out and look at the resulting code. It's not bad. It's strongly typed, field length is enforced and it's structured in a logical way that's usable, easy to modify/update and it will seriously save you a lot of time doing the heavy lifting for you. What it gives you can be changed in any way you see fit. I inherit it all into another class where I do some stuff to the values before they are passed and it's so easy to do. {/Edit}:thumbsup:

                                H Offline
                                H Offline
                                Howard Richards
                                wrote on last edited by
                                #36

                                Welcome to the club! :) It's just too easy to things with LINQ, despite the various drawbacks.

                                'Howard

                                1 Reply Last reply
                                0
                                • C code frog 0

                                  So here I am totally bogged down in reluctance to write more data access code and stored procedures. I hate it. It's tedious and bothersome. So... I google C# code generation SQL server and out pops this Linq result that talks about SQLMetal. Not having a clue at all what I'm looking at I bite. I open up the VS 2008 command prompt and type in:

                                  C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>sqlmetal /server:{server} /database:{db} /namespace:{new namespace} /code:{ClassName}.cs /language:csharp

                                  I hit enter and think this won't work. What do you know... Out pops a huge monolithic class that has all of the stuff required to Create/Insert/Update/Delete every table in the DB all VIA Linq. {Scratches Head} How the heck do I use this? Turns out a quick Google search and *BOOM* it's out of the park. No inline SQL, no stored procedures and no boredom. It's all done. I just invoke the class, instance my table populate the fields and then it's time to "Smile and Waive" as I call Submit(). I'm now a Linq convert. I will never go back. :cool:

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #37

                                  Hey! You converted me too! Nice stuff. However I resent this comment in the top of the resulting .cs-file: "// This code was generated by a tool." ...

                                  P 1 Reply Last reply
                                  0
                                  • D dbullen

                                    Hi I agree it's all cool, but i thought Linq to SQL was getting binned/de-supported/ignored? In favour of Entity Framework? Am I wrong? If nto, is it worth the investment? Dean

                                    C Offline
                                    C Offline
                                    code frog 0
                                    wrote on last edited by
                                    #38

                                    There is no investment. I just used it once for a project. It was cake. I cleaned it up. Made it pretty and used it. I've seen the comments on the Entity Framework. What is funny is the stuff I used is all Entity based which is confusing. So I think somehow I'm using the EF but anyway. I'll certainly investigate more. Just like everyone else. The key here is now that people know such things exist they will look for them and learn. Just like I'm doing. Had I not known then I would not have posted. Had I not posted then I would have taken much longer to learn about the EF. It's all good man.

                                    1 Reply Last reply
                                    0
                                    • M Member 96

                                      Allow me to retort: Every application that was built with an ORM code generator off a database (and no huge amount of hand tweaking) has a crappy UI that should be taken out and shot, not inflicted on an unsuspecting public. Code Generation without heavy tweaking = crappy software, it's axiomatic. The correct and necessary way to store data in a database and the tasks that the end users need to accomplish are 180 degrees apart and the business objects in a well crafted easy to use application bear little resemblance to the database schema. Our whole job as developers is not just to develop software, it's to abstract away the inner workings of computers and software and present the end user with something that looks and works how they think. If you start below the UI with business objects that are a perfect reflection of the database then you are led down a path that ends with crazy forms with rank upon rank of what are basically database fields exposed directly in the UI and a bunch of pointless extra work and confusion for the end user. People don't need developers for that, they can just hire a sql admin to make a database and users can just enter in the data in the tables directly. The point of being a developer is to be a crafstman who uses a combination of skill, and artistic ability to make the connection between the reality of the end users tasks they need to accomplish throughout their day and the separate reality of how data should be stored in a database. If you say you're using code generation for the heavy lifting then going back and heavily re-tweaking it for anything of consequence then that's fine but if you're generating the code then going on to the interface you're building a foundation on quicksand. And if you really are planning on hand tweaking LINQ has to be about the worst abomination to inflict upon yourself to no useful purpose I can imagine. Dense, unreadable, unmaintainable.... X|


                                      "It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson

                                      P Offline
                                      P Offline
                                      PIEBALDconsult
                                      wrote on last edited by
                                      #39

                                      Shoot, I can't vote 11?

                                      1 Reply Last reply
                                      0
                                      • L Lost User

                                        Hey! You converted me too! Nice stuff. However I resent this comment in the top of the resulting .cs-file: "// This code was generated by a tool." ...

                                        P Offline
                                        P Offline
                                        PIEBALDconsult
                                        wrote on last edited by
                                        #40

                                        Indeed, but I recall meeting a (COBOL) developer many years ago, his name was Atul.

                                        1 Reply Last reply
                                        0
                                        • C code frog 0

                                          I'm in a scrappy mood. I'm mostly serious about what I'm saying but I'm also having some fun too. Keep that in mind. :-\ Oh. Okay. Well you better quit using .Net because in case you haven't noticed... it's generated code written by the same guys. I'm not Elvis but I am letting this one go. Just doesn't mean that much to me at all. By the way I didn't vote you down either. I don't vote at all unless it's a 5. I never low vote. Anyway, if that's your battle cry head to war. I'll watch from the distance while I eat with my family and relax. The thing that kills me is you have zero clue how I'm using the code. God no I'm not parking a UI right on top of it. The UI hasn't even been written yet. The only thing I'm using it for is a data layer and that's it. I just wanted a simple class I could invoke to save to the DB. I'm so far away from building a UI it's not even funny. Yet you seem to assume that somehow I bound controls to the generated class and called it an application. Sorry. Haven't done that since... uh well I've uh never done that. Your whole tone is condescending like you are some all knowing wise man sitting on top of your golden mountain populated with coffee beans that you fart out of nothing. You don't have a clue what I'm doing. How I'm doing it or anything else. You start off about things like cocaine and sand and it makes no sense at all. Try asking more questions. Try actually understanding what a person is doing. Make sure you fully grasp what it is they are attempting and how it is they are attempting it. At that point make a suggestion but please don't pass judgment like some arcane ruler that sits on a cloud. It's annoying.

                                          M Offline
                                          M Offline
                                          Member 96
                                          wrote on last edited by
                                          #41

                                          :-D

                                          code-frog wrote:

                                          I just wanted a simple class I could invoke to save to the DB.

                                          I think it's a pretty natural assumption to assume that someone who is bothering to generate code in the first place is doing quite a bit more than making a little utility class.

                                          code-frog wrote:

                                          The only thing I'm using it for is a data layer and that's it

                                          That's how it starts, unfortunately the whole design is fundamentally broken at exactly this point, there's no where to go from here but wrong turns. At the risk of using another analogy it's like starting a trip to mars with your initial vector off .0001 degrees, by the time you get to the other end you've missed Mars completely.

                                          code-frog wrote:

                                          Your whole tone is condescending like you are some all knowing wise man sitting on top of your golden mountain populated with coffee beans that you fart out of nothing.

                                          :) Ah well I guess decades of success in the industry doesn't count for anything these days. I feel like I am qualified to make a case against code generation because I make huge commercial business apps that are very sucessful and I've tried and adopted every possible method to speed that process up while still putting out sellable software in a timely fashion; if code generation made any kind of sense I'd be the first guy in line to get some.

                                          code-frog wrote:

                                          At that point make a suggestion but please don't pass judgment like some arcane ruler that sits on a cloud. It's annoying.

                                          I'm sure it is annoying, doubly so when you know I'm right and have doubts about it yourself but initially wrote such a glowing endorsement of it that you have no room to go anywhere else with it. ;) Do what you want, I was only trying to help those with less experience that might take code generation seriously for anything that matters. :rose:


                                          "It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson

                                          O 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