Category Archives: LINQ

2009 Predictions – ASP.NET, LINQ 2 SQL, VB and C# are dead

These are predictions by Guy Barrette who is Microsoft Regional Director.

ASP.NET is dead
You should drop ASP.NET and start using Silverlight right now because it is clear that Microsoft has no roadmap and future plans for that technology. At the last PDC, nothing new ASP.NET was announced except a few tweaks for AJAX and the fact that Microsoft released the MVC Framework proves that but IMHO, the MVC Framework is just a toy technology to shut the Agile loudmouths that wants to code everything by hand and reinvent the wheel.

BizTalk is dead
With Dublin coming up with the Framework 4.0, it makes no sense to purchase and invest in BizTalk anymore. Why spend gazillions of dollars when you’ll have the exact same services for free right in the Framework? Why being locked with a product when you get the API for free?

LINQ 2 SQL is dead
Microsoft recently stated that they have stopped working on LINQ 2 SQL to focus on the Entity Framework so why would you use LINQ 2 SQL anymore? Once again, Microsoft has released a new technology, people invested in that technology and Microsoft abandoned it without warnings. I’m not happy because I invested so much in LINQ 2 SQL so I think I’ll stick with ADO.NET fearing that Microsoft will eventually dropped the Entity Framework as well.

VB and C# are dead
At the last PDC, Microsoft showed Oslo, its modeling platform along with M, a modeling language. This will revolutionize the way we design and build applications. In the near future we will no longer code using low level languages like VB and C#. I would stop investing in these languages right now and train my whole team in M.

Azure is DOA
Cloud computing, talk about something so stupid its name is stupid. Why the heck would I push my apps and data in Microsoft’s data centers? I don’t get it and I think no one will use that technology and trust Microsoft. This thing is dead even before it will be released (.NET My Services anyone?).

OK, you must have seen similar comments everywhere in forums, blogs or talking with colleagues and other developers but is any of this making sense?

AP.NET vs Silverlight vs MVC Framework
When I was at the last PDC, one thing that struck me was the fact that no major new announcements were made for ASP.NET. Clearly, this is the sign of a mature technology but at the same time, Microsoft is putting a lot of resources and efforts in building a new platform in Silverlight. Does that mean that you should drop ASP.NET? Of course not: it’s mature, it’s stable, hundreds of 3rd party controls are available, it’s proven and you can find thousands of developers familiar with that technology. Why would you stop using it all of a sudden? But why is Microsoft working so hard on Silverlight? Because Silverlight fills the RIA gap in the Microsoft offer because developing complex RIA apps with AJAX is way too costly right now. So why is Microsoft working on the MVC Framework, a direct competitor to ASP.NET? Again, another model to solve different problems. It’s easier to use if you’re deep into TDD, it’s somewhat lighter but at the same time, it’s somewhat a return to Classic ASP. Well, it’s another tool in your .NET toolbox and this creates confusion for people who think in the “one size fits all / one ring to rule them all” way. Again, look at your project/assignment, analyse the problem/need and select the right technology to do the job. But in the long time, could Silverlight be so successful that it would replace ASP.NET? Maybe or maybe not. It certainly has the potential to do so but who knows at this point in time!

2009 prediction: ASP.NET will dominate and we will see a slow but steady Silverlight adoption. The MVC Framework will remain a niche tool for Agilists for now (and I’m not saying this in a pejorative way).

BizTalk vs Dublin
The .NET Framework 4.0 will include a set of extensions to Windows Server that will add new services to Microsoft’s app server. Features that will simplify the deployment, configuration, management, and scalability of WCF and WF applications. Basically, some of the same features found in BizTalk Server. So why would I bother with BizTalk and spend big money when I can get the same services for free? Well, BizTalk is an integration server and Dublin is a set of management tools extending Microsoft app server. Dublin will allow you to deploy more easily your WCF apps so instead of writing a Windows service to host your WCF services, the app server will be able to host them directly.
So you think you can write a BizTalk clone? Remember how BizTalk 1 was a piece of ****? And remember BizTalk 2? Microsoft only got it right with version 3 so yes, you can write a BizTalk clone using Dublin but it will cost you a lot more than purchasing BizTalk because Dublin and BizTalk are two different animals.

2009 prediction: Dublin will be widely used right away to help host WCF apps. BizTalk will not die and some people will get burned by trying to replace BizTalk with Dublin in a scenario where the use of BizTalk would have make more sense. FUD will run loose on the Web.

LINK 2 SQL vs Entity Framework
So Microsoft created some confusion by releasing two similar ORM technologies? Yes of course but if you look closely, they are somewhat similar and different at the same time. LINQ 2 SQL is RAD against SQL Server and the Entity Framework is the full blown ORM thing. Both use LINQ as the query language so if you invested in LINQ 2 SQL, your investment is not wasted and for God’s sake, LINQ 2 SQL is in the Framework; it cannot die!
One suggestion that I saw on the Web was to release LINQ 2 SQL on CodePlex so that people can update it since Microsoft has “abandoned” it. First, Microsoft never said that it has abandoned it. They will keep it as it is right now and they will put all their efforts on the Entity Framework. My hope is that when we’ll see new SQL Server releases, Microsoft will update LINQ 2 SQL to match some of the new features. So back to the CodePlex idea: I think it’s a bad one because people will try to match the features of the Entity Framework or Nhibernate and that will create more confusion because we will have similar products competing against each other.

LINQ 2 SQL = simple 1 to 1 mapping against SQL Server
Entity Framework = complex mapping against SQL Server and more

2009 prediction: people will still be confused and FUD will run loose on the Web

C# and VB vs Oslo
Microsoft have finally abandoned the traditional design surface where we connect little boxes as the way to model apps and I think that Oslo and M are very good concepts. Is this the modeling Holy Grail? I have no idea but it looks good. Can Oslo and M replace VB and C#? Of course not!
Every time that Microsoft launched a new way to model apps, these technologies never lasted more than one version. I would tend to have a wait and see approach. Take a look, experiment and wait for version 2.

2009 prediction: Olso and M will be curiosities. Let’s hope that they will not die as the other Microsoft modelling oddities.

Azure vs apps hosted in the enterprise
Microsoft has taken a bold approach to cloud computing. Instead of hosting your virtual machines running your apps, they will host your apps in a new cloud OS running in their virtual machines. But why would you do that? To drive IT costs down of course. Look, there’s something called a recession going on right now and it’s a nasty one. At some point, your boss will be asked by his/her boss to cut expenses drastically and maybe one way to do it is to go the cloud way. We’ll see but there’s one thing that I’m sure: this will be another tool in your .NET arsenal and it will not make sense to write all apps to run in the cloud. Again, look at your project/assignment, analyse the problem/need and select the right technology to do the job. I’m sure that people will get burned by using the cloud model on projects where it doesn’t make sense.

2009 prediction: Microsoft has a lot of work to do to convince people to move to cloud computing.

Three new free books from Microsoft

Sorry for not writing lately but I have been distracted with some other projects. Here are some interesting books I came across yesterday. Enjoy!

Programming Microsoft® ASP.NET 3.5
ms asp net cvr Three new free books from Microsoft

Programming Microsoft LINQ
ms linq cvr Three new free books from Microsoft

Introducing Microsoft® SilverlightTM 2 Second Edition
ms silverlight cvr Three new free books from Microsoft

Free Microsoft Press e-books!

Once again Microsoft brings some knowledge to the masses icon smile Free Microsoft Press e books! This time its free e-books. All the headings speak for them selfs and with few words these books are MUST HAVE for every developer. Only few chapters are included in pdf’s as you are encouraged to buy them! Here is the content:

ms linq cvr Free Microsoft Press e books!Introducing Microsoft LINQ
by Paolo Pialorsi and Marco Russo

ISBN: 9780735623910

* Chapter 1: LINQ Introduction
* Chapter 2: C# Language Features
* Chapter 3: Visual Basic 9.0 Language Features
* Chapter 4: LINQ Syntax Fundamentals
* Chapter 5: LINQ to ADO.NET
* Chapter 6: LINQ to XML

ms ajax cvr Free Microsoft Press e books!Introducing Microsoft ASP.NET AJAX
by Dino Esposito

ISBN: 9780735624139

* Chapter 1: The AJAX Revolution
* Chapter 5: The AJAX Control Toolkit

ms silverlight cvr Free Microsoft Press e books!Introducing Microsoft Silverlight 1.0
by Laurence Moroney

ISBN: 9780735625396

* Chapter 1: Silverlight and User Experience
* Chapter 5: Programming Silverlight with JavaScript

Log into Microsoft Press home page for more info here

Converting SQL to LINQ – DISTINCT, WHERE, ORDER BY and Operators

Bill Horst continues with those simple examples. After this one here comes the other set. They are perfect to show basic syntax. Here are few more:

DISTINCT
SQL SELECT statements can include the DISTINCT specifier, which causes all duplicate records in the query result to be removed. In a LINQ expression, Distinct is its own individual clause, rather than a specifier on the Select clause. This means that Distinct can appear between any two other clauses. The Distinct clause takes whatever result is returned by the preceding clause (Select, in the case below) and returns a filtered result with duplicates removed. To two code examples below accomplish the same results:

SQL

SELECT DISTINCT Name, Address
FROM CustomerTable

VB

From Contact In CustomerTable _
Select Contact.Name, Contact.Address _
Distinct

ORDER BY
The SQL ORDER BY clause can also be represented in a LINQ expression. A LINQ Order By clause allows for a comma-delimited list of expressions to specify how results should be sorted. Any valid VB expression can be used, so these expressions don’t necessarily have to be the names of field that were selected.

SQL

SELECT * FROM CustomerTable
ORDER BY Phone

VB

From Contact In CustomerTable _
Order By Contact.Phone

ASC/DESC
A SQL ORDER BY clause can also include ASC and DESC keywords, to specify that the sort should be in ascending or descending order, respectively. VB uses Ascending and Descending keywords for the same purpose, with the same syntax. If neither specifier is present, ascending order is the default.

SQL

SELECT * FROM CustomerTable
ORDER BY Phone ASC, Name DESC

VB

From Contact In CustomerTable _
Order By Contact.Phone Ascending, Contact.Name Descending

Here is the original post by Bill Horst

Converting SQL to LINQ

This is a series of posts regarding the new language improvements in VB 9. Bill Horst has written the second on which I came across here. As we all know VB LINQ statements enable SQL-like syntax for queries in the VB language. LINQ syntax doesn’t match SQL syntax exactly, so if you are already working with SQL or familiar with SQL queries, you may find yourself wanting to convert an existing SQL query to LINQ.

And here is an example with FROM clause:

A SQL SELECT statement always begins with a SELECT Clause, followed by a FROM Clause. A VB query expression always begins with a From Clause or Aggregate Clause (Aggregate will be discussed later). A basic SQL FROM clause specifies a table over which to query, and similarly, a LINQ From Clause specifies an object over which to query (CustomerTable). This object could represent “In-Memory” data, a SQL data table, or XML information. My examples use the “In-Memory” case, since it allows the simplest code. In addition to this data object, the VB From clause always includes an identifier for the current “row” (Contact), which basically functions as an alias.

SQL

SELECT Contact.CustomerID, Contact.Phone
FROM CustomerTable Contact

LINQ

From Contact In CustomerTable
Select Contact.CustomerID, Contact.Phone

Here is the whole post by Bill Horst.

In it training, the order of courses matters a lot. Doing 70-290 after 70-270 makes more sense rather than the vice versa. This holds true for 70-291 as well. A 642-901 should be attempted after 642 series, not something as basic as 70-297.

Visual Studio 2008 and .NET 3.5 Released

Today Microsoft shipped Visual Studio 2008 and .NET 3.5. You can download the final release using one of the links below:

* If you are a MSDN subscriber, you can download your copy from the MSDN subscription site (note: some of the builds are just finishing being uploaded now – so check back later during the day if you don’t see it yet).

* If you are a non-MSDN subscriber, you can download a 90-day free trial edition of Visual Studio 2008 Team Suite here. A 90-day trial edition of Visual Studio 2008 Professional (which will be a slightly smaller download) will be available next week. A 90-day free trial edition of Team Foundation Server can also be downloaded here.

*If you want to use the free Visual Studio 2008 Express editions (which are much smaller and totally free), you can download them here.

* If you want to just install the .NET Framework 3.5 runtime, you can download it here.

List of New Featuresold version

VS 2008 Multi-Targeting Support
VS 2008 enables you to build applications that target multiple versions of the .NET Framework. This means you can use VS 2008 to open, edit and build existing .NET 2.0 and ASP.NET 2.0 applications (including ASP.NET 2.0 applications using ASP.NET AJAX 1.0), and continue to deploy these application on .NET 2.0 machines.

ASP.NET AJAX and JavaScript Support
.NET 3.5 has ASP.NET AJAX built-in (no separate download required). In addition to including all of the features in ASP.NET AJAX 1.0, ASP.NET 3.5 also now includes richer support for UpdatePanels integrating with WebParts, ASP.NET AJAX integration with controls like and , WCF support for JSON, and many other AJAX improvements.

VS 2008 Web Designer and CSS Support
VS 2008 and Visual Web Developer 2008 Express includes a significantly improved HTML web designer (the same one that ships with Expression Web). This delivers support for split-view editing, nested master pages, and great CSS integration.

Language Improvements and LINQ
The new VB and C# compilers in VS 2008 deliver significant improvements to the languages. Both add functional programming concepts that enable you to write cleaner, terser, and more expressive code. These features also enable a new programming model we call LINQ (language integrated query) that makes querying and working with data a first-class programming concept with .NET.

Data Access Improvements with LINQ to SQL
LINQ to SQL is a built-in OR/M (object relational mapper) in .NET 3.5. It enables you to model relational databases using a .NET object model. You can then query the database using LINQ, as well as update/insert/delete data from it. LINQ to SQL fully supports transactions, views, and stored procedures. It also provides an easy way to integrate business logic and validation rules into your data model.

Browsing the .NET Framework Library Source using Visual Studio

Lots of other improvements

The list above is only a small set of the improvements coming. For client development VS 2008 includes WPF designer and project support. ClickOnce and WPF XBAPs now work with FireFox. WinForms and WPF projects can also now use the ASP.NET Application Services (Membership, Roles, Profile) for roaming user data.

Office development is much richer – including support for integrating with the Office 2007 ribbon, and with Outlook. Visual Studio Tools for Office support is also now built-into Visual Studio (you no longer need to buy a separate product).

New WCF and Workflow projects and designers are now included in VS 2008. Unit testing support is now much faster and included in VS Professional (and no longer just VSTS). Continuous Integration support is now built-in with TFS. AJAX web testing (unit and load) is now supported in the VS Test SKU. And there is much, much more…

Installation Suggestions

People often ask me for suggestions on how best to upgrade from previous betas of Visual Studio 2008. In general I’d recommend uninstalling the Beta2 bits explicitly. As part of this you should uninstall Visual Studio 2008 Beta2, .NET Framework Beta2, as well as the Visual Studio Web Authoring Component (these are all separate installs and need to be uninstalled separately). I then usually recommend rebooting the machine after uninstalling just to make sure everything is clean before you kick off the new install. You can then install the final release of VS 2008 and .NET 3.5 on the machine.

Once installed, I usually recommend explicitly running the Tools->Import and Export Settings menu option, choosing the “Reset Settings” option, and then re-pick your preferred profile. This helps ensure that older settings from the Beta2 release are no longer around (and sometimes seems to help with performance).

Note that VS 2008 runs side-by-side with VS 2005 – so it is totally fine to have both on the same machine (you will not have any problems with them on the same box).

Silverlight Tools and VS Web Deployment Project Add-Ins

Two popular add-ins to Visual Studio are not yet available to download for the final VS 2008 release. These are the Silverlight 1.1 Tools Alpha for Visual Studio and the Web Deployment Project add-in for Visual Studio. Our hope is to post updates to both of them to work with the final VS 2008 release in the next two weeks. If you are doing Silverlight 1.1 development using VS 2008 Beta2 you’ll want to stick with with VS 2008 Beta2 until this updated Silverlight Tools Add-In is available.

Read Scott Gu

Новости в Visual Studio 2008 beta 2

Наскоро Microsoft представиха последните версии на Visual Studio 2008 и .NET 3.5 beta 2. Visual Studio 2008 можете да изтеглите от тук, а умалената експрес версия от тук. Важно е да отблежим, че новите версии можете да инсталирате съвместно с по-старата VS 2005.

Ето и някои от последните нововъведения в Visual Studio 2008:

- Поддръжка на Multi-Targeting – VS 2008 ви дава възможност да създавате приложения предназначени за различни версии на .NET Framework. Лесно може да се превключва от една версия на друга.

- VS 2008 Web Designer и поддръжка на CSS – в тази версия е включен подобрен HTML web designer. В него се поддържат ‘двоен’(сплит) изглед, внедрени една в друга master pages, и подобрена CSS поддръжка.

css Новости в Visual Studio 2008 beta 2

- ASP.NET AJAX и поддръжка на JavaScript – в .NET 3.5, ASP.NET AJAX е внедрен, както и са добавени нови функционалности като UpdatePanel с WebParts, поддръжка на WCF за JSON, и редица други подобрения по бързодействието. VS 2008 има и увеличена поддръжка относно интегрирането на JavaScript и AJAX в приложенията. Новото студио се отличава с подобрен Intellisense, който дори работи при включени външни JavaScript файлове.

js Новости в Visual Studio 2008 beta 2

- Езикови подобрения и LINQ – новите компилатори на VB и C# имат доста подобрения относно функциите на езиците. Това основно се забелязва при LINQ(language integrated query) който добавя нови възможности при заявки и работа с данни. Ето и някой от подобренията налични в C#:
o Automatic Properties, Object Initializer and Collection Initializers
o Extension Methods
o Lambda Expressions
o Query Syntax
o Anonymous Types
lambda Новости в Visual Studio 2008 beta 2

- Подобрен достъп до данни чрез LINQ към SQL
LINQ към SQL е внедрен OR/M (object relational mapper) в .NET 3.5. Той ви дава възможност да правите заявки чрез LINQ, както и да редактирате/изтривате и вмъквате нови записи. LINQ към SQL напълно поддържа транзакции, изгледи и запазени процедури.

dataaccess Новости в Visual Studio 2008 beta 2

Това са само някои от многото подобрения представени в новата версия. Дотук всичко е добре, но лично за мен остават отворени въпросите:
– Ще успеят ли да разработят всичките езикови подобрения и за Visual Basic?
– Ще успеят ли до Февруари 2008 да са готови с крайната версия?

Using LINQ to XML (and how to build a custom RSS Feed Reader with it)

Here is latest post from ScottGu’s blog. There he describes how to build a custom RSS Feed Reader using LINQ to XML. Check it out:

One of the big programming model improvements being made in .NET 3.5 is the work being done to make querying data a first class programming concept. We call this overall querying programming model “LINQ”, which stands for .NET Language Integrated Query.

LINQ supports a rich extensibility model that facilitates the creation of efficient domain-specific providers for data sources. .NET 3.5 ships with built-in libraries that enable LINQ support against Objects, XML, and Databases.


What is LINQ to XML?

LINQ to XML is a built-in LINQ data provider that is implemented within the “System.Xml.Linq” namespace in .NET 3.5.

LINQ to XML provides a clean programming model that enables you to read, construct and write XML data. You can use LINQ to XML to perform LINQ queries over XML that you retrieve from the file-system, from a remote HTTP URL or web-service, or from any in-memory XML content.

LINQ to XML provides much richer (and easier) querying and data shaping support than the low-level XmlReader/XmlWriter API in .NET today. It also ends up being much more efficient (and uses much less memory) than the DOM API that XmlDocument provides.


Using LINQ to XML to query a local XML File

To get a sense of how LINQ to XML works, we can create a simple XML file on our local file-system like below that uses a custom schema we’ve defined to store RSS feeds:

step2 Using LINQ to XML (and how to build a custom RSS Feed Reader with it)

I could then use the new XDocument class within the System.Xml.Linq namespace to open and query the XML document above. Specifically, I want to filter the elements in the XML file and return a sequence of the non-disabled RSS feeds (where a disabled feed is a element with a “status” attribute whose value is “disabled”). I could accomplish this by writing the code below:

VB:

step4 Using LINQ to XML (and how to build a custom RSS Feed Reader with it)

read whole article

LINQ to SQL (Part 5 – Binding UI using the ASP:LinqDataSource Control)

Hi all, I have been quite busy lately so didnt got much time to post here, but now will try to catch it up. Here is a post from Scott Guthrie which is PART 5 of his LINQ to SQL series:

Over the last few weeks I’ve been writing a series of blog posts that cover LINQ to SQL. LINQ to SQL is a built-in O/RM (object relational mapper) that ships in the .NET Framework 3.5 release, and which enables you to easily model relational databases using .NET classes. You can use LINQ expressions to query the database with them, as well as update/insert/delete data.

Below are the first four parts of my LINQ to SQL series:

In these previous LINQ to SQL blog posts I focused on how you can programmatically use LINQ to SQL to easily query and update data within a database.

In today’s blog post I’ll cover the new control that is shipping as part of ASP.NET in the upcoming .NET 3.5 release. This control is a new datasource control for ASP.NET (like the ObjectDataSource and SQLDataSource controls that shipped with ASP.NET 2.0) which makes declaratively binding ASP.NET UI controls to LINQ to SQL data models super easy.


Sample Application We’ll be Building

The simple data editing web application I’ll walkthrough building in this tutorial is a basic data entry/manipulation front-end for products within a database:

step03 LINQ to SQL (Part 5   Binding UI using the ASP:LinqDataSource Control)

The application will support the following end-user features:

  1. Allow users to filter the products by category
  2. Allow users to sort the product listing by clicking on a column header (Name, Price, Units In Stock, etc)
  3. Allow users to skip/page over multiple product listings (10 products per page)
  4. Allow users to edit and update any of the product details in-line on the page
  5. Allow users to delete products from the list

The web application will be implemented with a clean object-oriented data model built using the LINQ to SQL ORM.

All of the business rules and business validation logic will be implemented in our data model tier – and not within the UI tier or in any of the UI pages. This will ensure that: 1) a consistent set of business rules are used everywhere within the application, 2) we write less code and don’t repeat ourselves, and 3) we can easily modify/adapt our business rules at a later date and not have to update them in dozens of different places across our application.

We will also take advantage of the built-in paging/sorting support within LINQ to SQL to ensure that features like the product listing paging/sorting are performed not in the middle-tier, but rather in the database (meaning only 10 products are retrieved from the database at any given time – we are not retrieving thousands of rows and doing the sorting/paging within the web-server).

read original

LINQ to SQL (Part 3 – Querying our Database)

The third part from Scott Guthrie’s series LINQ to SQL:

Last month I started a blog post series covering LINQ to SQL. LINQ to SQL is a built-in O/RM (object relational mapping) framework that ships in the .NET Framework 3.5 release, and which enables you to easily model relational databases using .NET classes. You can then use LINQ expressions to query the database with them, as well as update/insert/delete data from it.

Below are the first two parts of my LINQ to SQL series:

In today’s blog post I’ll be going into more detail on how to use the data model we created in the Part 2 post, and show how to use it to query data within an ASP.NET project.


Northwind Database Modeled using LINQ to SQL

In Part 2 of this series I walked through how to create a LINQ to SQL class model using the LINQ to SQL designer that is built-into VS 2008. Below is the class model that we created for the Northwind sample database:

step1 LINQ to SQL (Part 3   Querying our Database)


Retrieving Products

Once we have defined our data model classes above, we can easily query and retrieve data from our database. LINQ to SQL enables you to do this by writing LINQ syntax queries against the NorthwindDataContext class that we created using the LINQ to SQL designer above.

For example, to retrieve and iterate over a sequence of Product objects I could write code like below:

step1 LINQ to SQL (Part 3   Querying our Database)

In the query above I have used a “where” clause in my LINQ syntax query to only return those products within a specific category. I am using the CategoryID of the Product to perform the filter.

One of the nice things above LINQ to SQL is that I have a lot of flexibility in how I query my data, and I can take advantage of the associations I’ve setup when modeling my LINQ to SQL data classes to perform richer and more natural queries against the database. For example, I could modify the query to filter by the product’s CategoryName instead of its CategoryID by writing my LINQ query like so:

step2 LINQ to SQL (Part 3   Querying our Database)

Notice above how I’m using the “Category” property that is on each of the Product objects to filter by the CategoryName of the Category that the Product belongs to. This property was automatically created for us by LINQ to SQL because we modeled the Category and Product classes as having a many to one relationship with each other in the database.

read original