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. Missing LINQ?

Missing LINQ?

Scheduled Pinned Locked Moved The Lounge
databasecsharplinqcomtools
78 Posts 33 Posters 5 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.
  • B BoneSoft

    Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


    Try code model generation tools at BoneSoft.com.

    S Offline
    S Offline
    Shog9 0
    wrote on last edited by
    #35

    I like it. So there. :->

    every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

    1 Reply Last reply
    0
    • B BoneSoft

      Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


      Try code model generation tools at BoneSoft.com.

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #36

      The reason Linq looks wierd is that, to get intellisense to work, they had to but the "subject" of the query in front. So, with DLinq, it's the table name. Otherwise intellisense wouldn't be able to help the lazybones programmer figure out the columns associated with the table. Marc

      Thyme In The Country
      Interacx
      My Blog

      B 1 Reply Last reply
      0
      • B BoneSoft

        Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


        Try code model generation tools at BoneSoft.com.

        N Offline
        N Offline
        NormDroid
        wrote on last edited by
        #37

        No reservations at all, it's the most natural technology to emerge from Microsoft for a long time.

        Chuck Norris counted to infinity - twice.

        1 Reply Last reply
        0
        • B BoneSoft

          Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


          Try code model generation tools at BoneSoft.com.

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #38

          BoneSoft wrote:

          But could it not have been more... SQL-like?

          Ummm - it pretty much *is* SQL, apart from the ordering of the statement clauses? This example off Wikipedia looks quite SQL-ish to me.

          var q = from o in db.Orders, c in db.Customers
          where o.Quality == "200" && (o.CustomerID == c.CustomerID)
          select new { o.DueDate, c.CompanyName, c.ItemID, c.ItemName };

          The other thing to remember is that LINQ is generalized across *anything*, so long as it implements the appropriate interface or methods. This makes it incredibly easy to perform operations on collections of objects, rather than having to loop over them. This feature is just one part of the migration into C# of features normally found in functional programming languages - type inference, lambdas, LINQ (pretty much equivalent to list comprehensions). Now, if they could work out how to safely add lightweight processes and message passing a la Erlang, .NET languages would really be in a good position to make good use of multicore chips. Of course, so long as you have shared, mutable state, you're always going to be in a position to have 'interesting' threading bugs.

          B 1 Reply Last reply
          0
          • C Colin Angus Mackay

            BoneSoft wrote:

            I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..."

            I would very much doubt that. LINQ is just syntactic sugar for a number of new classes that were added to the .NET Framework. You can perform the same thing but without using LINQ by just calling the appropriate methods. In fact that should be taught because it will show people how it is actually put together.

            BoneSoft wrote:

            But could it not have been more... SQL-like?

            No. The basis of C# and SQL are different. SQL is mostly a declarative set based language, while C# is procedural. (i.e. In SQL you say what you want and the query optimiser figures out how to get it. In C# you specify HOW you want it to function.) You can view LINQ as a hybrid of the two.

            BoneSoft wrote:

            Am I alone here or does anybody else have reservations about LINQ?

            My only reservation about LINQ is that I can see how newbies will be able to abuse it without fully understanding what is going on under the hood.


            Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

            M Offline
            M Offline
            Mitchell D Geere
            wrote on last edited by
            #39

            I think that MS did an awesome job on the .net languages and the framework. I am yet to see another language compare to C# and a framework compare to .NET I have used the open source cousin (mono) and wasnt to impressed, and I have used Java and still not impressed. Where MS do kinda drop the balls is with the IDE and that is where most of you get confused, you tightly associate the IDE with the framework at that time. Yes they have been released at the same time (except for v3.0 of the framework). Managed programming has for years now made it very easy for newbies to create disgusting code (Java is included here) so I really think it is an education thing. Programmers need to still under go the same trainning (whether that is personal or formal) that one use to back in the day before managed code. So they can learn about the repocutions of bad code. Have them understand memory and processing and io, and sorting algorithms etc. So that they dont just associate the idea of writing a file with system.io etc. but actually understand what the underlaying is doing. On linq I have been playing with this for a long time now. I think it is awesome, it is as said really just a mask of what is going on in the background. However from a coding efficiency it is great. Not sure how many of you have played with Rail systems like Ruby, or MVC frameworks like codeigniter etc. If you have you will appreciate Linq being here. All I have a gripe with is the IDE and would like to see something more solid in the future, I have been working with BETA 2 of Orcas for a while now as well and there still some bugs but I am hoping that gets sorted by the end of the year. ;)

            Mitchell Geere

            C 1 Reply Last reply
            0
            • B BoneSoft

              Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


              Try code model generation tools at BoneSoft.com.

              R Offline
              R Offline
              reshi999
              wrote on last edited by
              #40

              I attended the MIX:07 conference and all the Microsoft bods were hyping up LINQ as the next big thing, when they were not hyping up silverlight that is :-) From my initial play around I'd say its useful for dynamic apps where users shape their queries, and significantly reduces the amount of code required to get an ASP dataset - otherwise its performance sucks. So its good if you want to make code readable, but are not to worried about the time it takes to get your data.

              1 Reply Last reply
              0
              • B BoneSoft

                Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


                Try code model generation tools at BoneSoft.com.

                M Offline
                M Offline
                Mendelt
                wrote on last edited by
                #41

                It took me about 15 minutes to get started with linq. The biggest difference is that you have to type the from-part first so intellisense knows what hints to give you. The rest looks a bit too much like SQL for me because linq is very different from SQL. Tried querying XML-files yet? or arrays/collections?

                1 Reply Last reply
                0
                • B BoneSoft

                  Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


                  Try code model generation tools at BoneSoft.com.

                  P Offline
                  P Offline
                  peterwaine
                  wrote on last edited by
                  #42

                  Typing and intellisense on databases, tables and fields is what does it for me. Data source abstaction, the same syntax should work on and storeage medium. It looks and feels much more "modern". There are a plethora of ORM tools out there that "code generate" similar classes, not as well IMO. Also, here we are in 2007, using sophisticated OO languages (C# and other .NET derivatives, Java etc) and then theres T-SQL, looking like it's 1990.

                  1 Reply Last reply
                  0
                  • C Colin Angus Mackay

                    BoneSoft wrote:

                    I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..."

                    I would very much doubt that. LINQ is just syntactic sugar for a number of new classes that were added to the .NET Framework. You can perform the same thing but without using LINQ by just calling the appropriate methods. In fact that should be taught because it will show people how it is actually put together.

                    BoneSoft wrote:

                    But could it not have been more... SQL-like?

                    No. The basis of C# and SQL are different. SQL is mostly a declarative set based language, while C# is procedural. (i.e. In SQL you say what you want and the query optimiser figures out how to get it. In C# you specify HOW you want it to function.) You can view LINQ as a hybrid of the two.

                    BoneSoft wrote:

                    Am I alone here or does anybody else have reservations about LINQ?

                    My only reservation about LINQ is that I can see how newbies will be able to abuse it without fully understanding what is going on under the hood.


                    Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                    K Offline
                    K Offline
                    Kevinio
                    wrote on last edited by
                    #43

                    I pretty much agree with all the points made above. I have been playing around with LINQ for quite a while now and can see big benefits from having a set of features that allow you to query several different data types/structures using one common syntax. Yes it takes a little getting used to but don't all new languages/code implementations. Surely good practice as a coder dictates that you should understand the technologies and workings of the code you are implementing? On this basis I definatly agree that the methods/classes underlying this new feature set should be taught and explained as to grasp more fully the under the hood workings and to not be led blindly down an alley. I do have major revisions with LINQ however so far from my playing. The technology seems to be totally inadequate for a multi tier environment. Take a simple n tier environemnt, database, data layer, business layer, ui layer. For the data layer you create LINQ classes to query your data structures. Take this simple senario, your UI has a button that calls a method contained in your business layer, for example User.Login(). When this method is called you want your business layer to make a call to your data layer using LINQ. When you write the code in your business layer you use the new annonymous type keyword, var, to create a smaller subset of your customer object. for example: var _Cust = from c in DataLayer.Customers where c.UserName = "Some Name" and c.Password = "Password" select new {c.UserId, c.FirstName, c.Surname} So, in the senario above we have used projection to create a new annonymous type, which is a great complier trick on MS part. This saves us creating many different methods to return different data collections/structures for the same object etc. We can create them on the fly and loop through them etc. However here comes the point were it all comes unstuck as far as i can tell. We now want to return our new type to the UI layer so that we can use the data it contains to bind to our presentation layer. Pretty normal senario you would say, but guess what, you cannot return a annonymous data types from a method!!!! So a method trying to return a var data type will not compile. This to me seems totally crazy, microsoft give us this great power of type projection with some really neat compiler trickery but then prevent us from returning it from any of our methods which to me makes it un-usable in any n-tier system. Yes use it in a single layer in a void method but thats about all folks. How do

                    B C 2 Replies Last reply
                    0
                    • B BoneSoft

                      Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


                      Try code model generation tools at BoneSoft.com.

                      F Offline
                      F Offline
                      Frobro
                      wrote on last edited by
                      #44

                      You've made very little attempt to understand LINQ. However, the great thing about it is you never have to use it. You can happily continue in your blissful ignorance. The more enlightened among us will eagerly start leveraging the power and flexibility of being able to query RDMS, file and memory object data sources simultaneously, all with the effeciency of IDE and compiler support. We will shave off the many man-hours lost in 'debugging' in shoddy database management and scripting tools as we cruise along on a great layer of abstraction, increasing our productivity and competitive edge by several orders of magnitude. Resistance to change is common to the human condition, but I hope that you will overcome your unwillingness to learn a little extra syntax. Frankly, I'm convinced that LINQ is the natural evolution from the the mediocre-success attempts at object databases and object persistence frameworks that we've seen from various companies (e.g CodeGear ECO & DevExpress PO - both of which I have the utmost respect for). If you really wanna grasp this LINQ stuff, I suggest you watch the video of Charlie Calvert and Anders Hejlsberg explaining and discussing it in some depth. You can Google it. I hope it'll bring a little clarity and insight. You've gotta understand that SQL only does half the job. Generally, a developer does this: 1. Create a database in the RDMS 2. Write SQL queries, test them against the RDMS and store them somewhere (code, SP etc) 3. In the application write code to connect to RDMS and pass the raw SQL 4. Receive the raw data results from the RDBMS 5. Convert the results to code objects for manipulation in the application 6. Implement controls & code for the user to work with the data LINQ halves the steps and reduces the process to: 1. Create a database in the RDMS 2. Write LINQ queries within IDE 3. Implement controls & code for the user to work with the data What a pleasure! Less cumbresome donkeywork and the same results and performance. Brilliant! Plus I get to query a whole bunch of other stuff (even combine the queries) and not have to worry about loading, drivers, query translation. Man, I think I'm getting a woodie... Note that you use wizards in the IDE to establish a framework for your LINQ queries (it connects to the RDMS and automatically generates code objects that the LINQ queries will work with).

                      B 2 Replies Last reply
                      0
                      • B BoneSoft

                        Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


                        Try code model generation tools at BoneSoft.com.

                        J Offline
                        J Offline
                        Josh Fischer
                        wrote on last edited by
                        #45

                        I think you are assuming that LINQ is solely intended to be a SQL replacement which it is not. It is meant to be (yet another) layer of abstraction that allows you to interact with the query related aspects of databases, XML, DataSets and even your business objects in a common fashion. I have no special love for M$ and tend to agree with the other posts that we should wait and see how the final (or second) version turns out, but I think we may find it to be a useful tool. The use of attributes on class and property names is very similar to what I do to simply query generation and sproc parameter passing in my own code. Having something like that built into the framework (or is it technically a langugue feature?) should be nice. I have found that the main project page has some good information.

                        Josh Fischer

                        1 Reply Last reply
                        0
                        • C Colin Angus Mackay

                          Clickok wrote:

                          .Net Framework is here since 2002 and it isn't neither nice or usable...

                          I'd have to disagree with that. I'm very happy with it. And I'm looking forward to the enhancements in 2008.


                          Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                          L Offline
                          L Offline
                          LeonardReinhart
                          wrote on last edited by
                          #46

                          LINQ is sweet. It allows you to drag and drop tables and stored procedures onto a work surface that causes objects to be built that will interface with the database. Can you say business objects? You can then take those objects and drop them on a form and create either multiple entry (grid) or single entry representations of the tables. You can then display table data and update it back in the database without writing any code. Fairly complex data binding can be accomplished by editing properties on the fields. The business objects can have code added to them that reflects business logic. Acropolis is nice and Silverlight 1.1 is really nice and will run anywhere when the Moonlight version is complete. -- modified at 8:41 Tuesday 25th September, 2007

                          Len

                          1 Reply Last reply
                          0
                          • F Frobro

                            You've made very little attempt to understand LINQ. However, the great thing about it is you never have to use it. You can happily continue in your blissful ignorance. The more enlightened among us will eagerly start leveraging the power and flexibility of being able to query RDMS, file and memory object data sources simultaneously, all with the effeciency of IDE and compiler support. We will shave off the many man-hours lost in 'debugging' in shoddy database management and scripting tools as we cruise along on a great layer of abstraction, increasing our productivity and competitive edge by several orders of magnitude. Resistance to change is common to the human condition, but I hope that you will overcome your unwillingness to learn a little extra syntax. Frankly, I'm convinced that LINQ is the natural evolution from the the mediocre-success attempts at object databases and object persistence frameworks that we've seen from various companies (e.g CodeGear ECO & DevExpress PO - both of which I have the utmost respect for). If you really wanna grasp this LINQ stuff, I suggest you watch the video of Charlie Calvert and Anders Hejlsberg explaining and discussing it in some depth. You can Google it. I hope it'll bring a little clarity and insight. You've gotta understand that SQL only does half the job. Generally, a developer does this: 1. Create a database in the RDMS 2. Write SQL queries, test them against the RDMS and store them somewhere (code, SP etc) 3. In the application write code to connect to RDMS and pass the raw SQL 4. Receive the raw data results from the RDBMS 5. Convert the results to code objects for manipulation in the application 6. Implement controls & code for the user to work with the data LINQ halves the steps and reduces the process to: 1. Create a database in the RDMS 2. Write LINQ queries within IDE 3. Implement controls & code for the user to work with the data What a pleasure! Less cumbresome donkeywork and the same results and performance. Brilliant! Plus I get to query a whole bunch of other stuff (even combine the queries) and not have to worry about loading, drivers, query translation. Man, I think I'm getting a woodie... Note that you use wizards in the IDE to establish a framework for your LINQ queries (it connects to the RDMS and automatically generates code objects that the LINQ queries will work with).

                            B Offline
                            B Offline
                            BoneSoft
                            wrote on last edited by
                            #47

                            Frobro wrote:

                            You've made very little attempt to understand LINQ

                            Thanks Mr. Obvious, I'm glad you caught what was plainly spelled out for you. That was a well established fact from the initial post, and reiterated throughout the thread.

                            Frobro wrote:

                            You can happily continue in your blissful ignorance. The more enlightened among us... blah blah blah

                            And I appreciate the personal attack oh enlightened one, may Budha be with you too. But I must admit, after that introduction I didn't bother to read the rest of your Post. Maybe later today. Cheers :)


                            Try code model generation tools at BoneSoft.com.

                            B 1 Reply Last reply
                            0
                            • B BoneSoft

                              Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


                              Try code model generation tools at BoneSoft.com.

                              S Offline
                              S Offline
                              Steve Naidamast
                              wrote on last edited by
                              #48

                              Finally, another one who has the wisdom to ask the question, "Do we really need a new query language for data access in .NET?"... The answer is no!!! ORM software and other such tools like LINQ do nothing to increase the efficiency of data access in .NET applications. In fact, they make it worse by adding yet another "layer of abstraction" into our work which also increases maintenance overhead. As one technician said earlier this year, if you want to work with object related to your data acces than use an object-oriented database. ORM software, though an interesting concept, is a waste of time for both the technicians to learn and the applications to use.

                              Steve Naidamast Black Falcon Software, Inc. blackfalconsoftware@ix.netcom.com

                              1 Reply Last reply
                              0
                              • B BoneSoft

                                Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


                                Try code model generation tools at BoneSoft.com.

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

                                Enters the MS Fan Boy Old Man: LINQ Yes.. LINQ Yes.. ?? LINQ is not just another data layer tool or some technology to destroy n-tier model as some seem to think. It is not just some toy for play. Microsoft has a much larger picture with LINQ which is basically a unified approach at searching, managing, grouping and ordering data no matter what form it takes. Does not matter if it is a simple array in memory, an XML file or a database, data is handled very much the same way allowing to understand one technology to cover all those different needs. Unification is the goal and LINQ is the answer. Many developers do not see the big picture and still think that you would only use LINQ every now and then. I use it often! My data layer is built on LINQ and internal business objects are handled by LINQ along with global internal application data that I need to search or organize. If there is a collection of data, there I will be with my LINQ queries. With LINQ it is a simple task to deal with data that is relational or heirarchical such as XML. It allows me to deal with data as objects and build new objects out of data. The LINQ 2 SQL is pretty cool but you have to watch out that you do not get bit by a large number of hits to the database, but can be managed with a little care. LINQ 2 SQL can take a lot of the work out of the databse handling if you trust in it to do the work for you. To start with, I approached it much like ADO.NET and building out Sprocs for most of the work, but found that LINQ 2 SQL does a fairly good job (and I expect even better in the future versions) generating everything that is needed without all the extra developer time to do it. It can handle some complicated queries (nested joins and groupings) without much effort. One of the first stumbling blocks in LINQ is the syntax. It is much like learning a new SQL language and many tend to fight learning something new. The first error is to approach LINQ as you would SQL, they are quite different beasts. As an example, you comment that you think the query is backwards, but really, once you are use to the syntax, you think SQL is backwards :) That is the point, you need to approach it with an open mind and be flexible. After just a couple of weeks, a developer should be confortable and enjoy the time savings from use LINQ all over the place. I still advice keeping the database access portion in a data layer abstracted from the rest of the application, but it does do a decent job at generating objects

                                B 1 Reply Last reply
                                0
                                • C Colin Angus Mackay

                                  Scott Dorman wrote:

                                  Right now there isn't anyone at Microsoft focused specifically on LINQ and getting the word out about it.

                                  I don't know... Daniel Moth, one of the UK's DPEs, has done quite a good job in some of his presentations. http://www.danielmoth.com/Blog/2007/02/decomposing-linq.html[^] Skip to the last code sample to see what it looks like without LINQ. Daniel has got quite a good series of blog posts on LINQ. I've also got some information on LINQ and some of the new language constructs in C# 3.0: * Anonymous Types[^] * Method Extensions[^] * Automatic Properties[^] * A start on LINQ[^] * Object Initialisers I[^] * Object Initialisers II[^] * Object Initialisers III[^]


                                  Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                                  C Offline
                                  C Offline
                                  codebozo
                                  wrote on last edited by
                                  #50

                                  Well said! Here is a link to Part 9 of Scott Guthrie's blogs on new 2008 features. The part 9 post contains links to the previous 8 parts. http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx[^]

                                  1 Reply Last reply
                                  0
                                  • B BoneSoft

                                    Is anybody else more than just a little uneasy about LINQ? The few examples I've seen make no sense to me. And I can't see what drove them to this solution either. I picture somebody at MS saying "ya know, let's take this well known standardized perfectly good query language that everybody is used to, chuck it out the window, and make a cryptic bizzare syntax built into the language itsef..." Ok, I can see some advantages to having it built it to the languages, not least of all avoiding the need for string storage and manipulation. But could it not have been more... SQL-like? Am I alone here or does anybody else have reservations about LINQ? And I know there are some people out there that are really excited about it, I'd like to hear what they have to say too.


                                    Try code model generation tools at BoneSoft.com.

                                    J Offline
                                    J Offline
                                    JPaula
                                    wrote on last edited by
                                    #51

                                    MY main interest is the possibility of dealing with XML directly in code, instead of having to deal with strings and XML api's. The rest seems a bit odd - like SQL but not exactly :confused: JP

                                    B 1 Reply Last reply
                                    0
                                    • K Kevinio

                                      I pretty much agree with all the points made above. I have been playing around with LINQ for quite a while now and can see big benefits from having a set of features that allow you to query several different data types/structures using one common syntax. Yes it takes a little getting used to but don't all new languages/code implementations. Surely good practice as a coder dictates that you should understand the technologies and workings of the code you are implementing? On this basis I definatly agree that the methods/classes underlying this new feature set should be taught and explained as to grasp more fully the under the hood workings and to not be led blindly down an alley. I do have major revisions with LINQ however so far from my playing. The technology seems to be totally inadequate for a multi tier environment. Take a simple n tier environemnt, database, data layer, business layer, ui layer. For the data layer you create LINQ classes to query your data structures. Take this simple senario, your UI has a button that calls a method contained in your business layer, for example User.Login(). When this method is called you want your business layer to make a call to your data layer using LINQ. When you write the code in your business layer you use the new annonymous type keyword, var, to create a smaller subset of your customer object. for example: var _Cust = from c in DataLayer.Customers where c.UserName = "Some Name" and c.Password = "Password" select new {c.UserId, c.FirstName, c.Surname} So, in the senario above we have used projection to create a new annonymous type, which is a great complier trick on MS part. This saves us creating many different methods to return different data collections/structures for the same object etc. We can create them on the fly and loop through them etc. However here comes the point were it all comes unstuck as far as i can tell. We now want to return our new type to the UI layer so that we can use the data it contains to bind to our presentation layer. Pretty normal senario you would say, but guess what, you cannot return a annonymous data types from a method!!!! So a method trying to return a var data type will not compile. This to me seems totally crazy, microsoft give us this great power of type projection with some really neat compiler trickery but then prevent us from returning it from any of our methods which to me makes it un-usable in any n-tier system. Yes use it in a single layer in a void method but thats about all folks. How do

                                      B Offline
                                      B Offline
                                      BoneSoft
                                      wrote on last edited by
                                      #52

                                      Yeah, that's disturbing to hear. I may have to investigate it some to see if there is a way around that. Like I said in the initial post, a lot of people seem to be really excited about it. So I assume there are good points of interest.


                                      Try code model generation tools at BoneSoft.com.

                                      1 Reply Last reply
                                      0
                                      • M Marc Clifton

                                        The reason Linq looks wierd is that, to get intellisense to work, they had to but the "subject" of the query in front. So, with DLinq, it's the table name. Otherwise intellisense wouldn't be able to help the lazybones programmer figure out the columns associated with the table. Marc

                                        Thyme In The Country
                                        Interacx
                                        My Blog

                                        B Offline
                                        B Offline
                                        BoneSoft
                                        wrote on last edited by
                                        #53

                                        It's almost a bit disturbing that they would base language design decisions on IDE requirements. But then again, language design can be based on lots of things, and in some ways I'm complaining about it's aesthetics.


                                        Try code model generation tools at BoneSoft.com.

                                        1 Reply Last reply
                                        0
                                        • S Stuart Dootson

                                          BoneSoft wrote:

                                          But could it not have been more... SQL-like?

                                          Ummm - it pretty much *is* SQL, apart from the ordering of the statement clauses? This example off Wikipedia looks quite SQL-ish to me.

                                          var q = from o in db.Orders, c in db.Customers
                                          where o.Quality == "200" && (o.CustomerID == c.CustomerID)
                                          select new { o.DueDate, c.CompanyName, c.ItemID, c.ItemName };

                                          The other thing to remember is that LINQ is generalized across *anything*, so long as it implements the appropriate interface or methods. This makes it incredibly easy to perform operations on collections of objects, rather than having to loop over them. This feature is just one part of the migration into C# of features normally found in functional programming languages - type inference, lambdas, LINQ (pretty much equivalent to list comprehensions). Now, if they could work out how to safely add lightweight processes and message passing a la Erlang, .NET languages would really be in a good position to make good use of multicore chips. Of course, so long as you have shared, mutable state, you're always going to be in a position to have 'interesting' threading bugs.

                                          B Offline
                                          B Offline
                                          BoneSoft
                                          wrote on last edited by
                                          #54

                                          True enough, that does look like mangled SQL. Maybe the inital examples that were out when I first started looking at it weren't the best.


                                          Try code model generation tools at BoneSoft.com.

                                          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