Nov 28 2007

let clause in C#

Category:Bil@l @ 11:16

I have discovered a new reserved C# word called let. "let" can be used inside your LINQ queries to store the result of a sub-expression that can be used in subsequent sections of the query.

For example, here is a sample from MSDN:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TestingApp
{
    class Test
    {
        public static void Main()
        {
            string[] strings =
        {
            "A penny saved is a penny earned.",
            "The early bird catches the worm.",
            "The pen is mightier than the sword."
        };

            // Split the sentence into an array of words
            // and select those whose first letter is a vowel.
            var earlyBirdQuery =
                from sentence in strings
                let words = sentence.Split(' ')
                from word in words
                let w = word.ToLower()
                where w[0] == 'a' || w[0] == 'e'
                    || w[0] == 'i' || w[0] == 'o'
                    || w[0] == 'u'
                select word;

            // Execute the query.
            foreach (var v in earlyBirdQuery)
            {
                Console.WriteLine("\"{0}\" starts with a vowel", v);
            }

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }

}

You can notice the two bold lines above. In the first line, we are setting the variable words to be a collection of all the words inside a single sentence, hence the type of words is now IEnumerable<string>.

In the second statement, we are querying the words variable (we can do this since words is IEnumerable<string> == Queryable Type) and letting the variable w hold the lowercase for each word in the words.

You can see how useful it is in some cases to cache an expression inside a let clause variable and then reference it later on in the query.

 

HTH,
Regards

Tags:

Nov 27 2007

System.Data.DataSetExtensions Exception in VS 2008 RTM

Category:Bil@l @ 21:15

I got the exception shown below when I opened an application that was developed under VS 2008 beta 2:

ASP.NET runtime error: Could not load file or assembly 'System.Data.DataSetExtensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified

 

What happened is that, there is no more an assembly System.Data.DataSetExtensions with version number 2.0. There is a new version for the same assembly name under 3.5.0.0.

To resolve the problem, simply right-click on the web application, properties, then remove the reference to the 2.0.0.0 assembly.

Then, right-click on the web application solution, Add Reference, locate the System.Data.DataSetExtensions and add a reference to it. This shall solve your problem!

 

HTH,
Regards


CCIE routing and switching written exam 350-001 by Cisco buffs up a candidate’s networking skills. You can develop skills to pass VM Ware certified professional VCP-310 exam online. Exam guides to pass CCNA 640-802 tests are easily available online. Microsoft MCSE 2003 70-290 are written and complied authentic networking experts.

Tags:

Nov 27 2007

Client Application Services

Category:Bil@l @ 19:18

I have noticed today something new in the VS 2008 (Orcas) and .NET 3.5 which is Client Application Services. As I understood, since in ASP.NET 2.0 you have Application Services which includes Membership, Role, and Profile services, they can be only used in ASP.NET world. But what about Windows-Based applications? How can they access those services so that both a Web application and a Windows application can share the same data?

The solution by creating Client Application Services which help you use those services.

I will be posting several posts on this topic very soon and show you how easy it is to use the above mentioned services in your Windows-Based applications!

 

HTH,
Regards

Tags:

Nov 27 2007

Silverlight 1.1 Tools for Visual Studio 2008 available for download

Category:Bil@l @ 06:47

There is a new updated version of the Silverlight 1.1 Tools for Visual Studio 2008 that works with the latest release of the Visual Studio 2008.

You can read more about it here: http://blogs.msdn.com/webdevtools/archive/2007/11/27/silverlight-1-1-tools-for-visual-studio-2008-available-for-download.aspx

 

Hope this helps,
Regards

 


Sony car cd mp3 players are remarkable all-in-one in-car communication devices. New models of laptop computers by Sony are also superb in terms of features and durability. Sony computers Vaio PCV-RS220 has good internet explorer which is excellent for photoshop, and acrobat games for children run well. Its good to read reviews before buying a desktop computer.

Tags:

Nov 24 2007

Unit Testing in Visual Studio 2008 Professional

Category:Bil@l @ 20:20

I have been browsing through the Visual Studio 2008 Training Kit and noticed on one of the slides that Unit Testing is now available in VS 2008 Professional.

I believe this is great and forces people to use unit testing even if companies or individuals cannot handle buying the VSTS, which in my opinion is very expensive for companies, how will it be for individuals?

 

Hope this hint helps,
Regards

Tags:

Nov 22 2007

Lebanese Independence Day

Category:Bil@l @ 15:06

Today is the Lebanese 64’Th Independence Day which is on the 22nd of November of every year.