Practical .NET

Not Using LINQ Yet? Here's a Few Reasons Why.

Peter Vogel introduces a new column on application development in the real world, and begins by advocating for Language Integrated Query.

Microsoft and magazines like this one have been telling you to adopt LINQ and Entity Framework for what seems like years. The main reason that you haven't done so is, probably, because you're smart. Smart developers build up a body of what I call "programmer lore" -- all the knowledge that you accumulate while you build applications in a particular technology. This includes all the standard solutions you keep in your mental toolbox, the generalized code you use in multiple applications, the cut-and-paste code you move from one program to another, and more. Programmer lore is knowing what the compiler's error messages really mean.

When it comes to data access, you've probably built up a working knowledge of SQL -- you can pretty much get SQL to do what you need. You've probably assembled a personal toolkit with some combination of writing raw SQL, a graphical tool for building SQL and ADO.NET. Your fingers can probably automatically type out the five or eight lines of code to create and open a connection, define a command object, call the ExecReader method and loop through the retrieved records.

And you know that you'll need to learn a bunch of new stuff to really use LINQ. During that period your productivity will be reduced, but your deadlines won't change. Finally, there are surely things you'll want to do in LINQ that, currently, your fingers won't type out automatically.

I'm here to help. It's time to give up ADO.NET and SQL and commit to the potent combination of LINQ and Entity Framework. Instead of writing all that ADO.NET code, line by painful line, you'll declare what you want with LINQ, and LINQ/Entity Framework will write the code for you.

The code that's generated by the LINQ/Entity Framework combination is, effectively, code written by the people who designed .NET and ADO.NET. I don't know if these people are smarter than me or you (though I have my suspicions), but they do know a great deal more about how those underlying technologies work. Trust me, you want their code.

Check out my Practical .NET column, Why You Really Should Be Using LINQ, for more on this compelling data access technology.

About the Author

Peter Vogel is a system architect and principal in PH&V Information Services. PH&V provides full-stack consulting from UX design through object modeling to database design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His blog posts on user experience design can be found at http://blog.learningtree.com/tag/ui/.

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube