19 November 2007

.NET Framework 3.5 and VS 2008 Released

Visual Studio 2008 and .NET Framework 3.5 have been finally released.
For more information and downloads, click here.

13 November 2007

ASP.NET MVC Framework

There is a nice post about ASP.NET MVC Framework on ScottGu's Blog.

The ASP.NET MVC Framework will provide built-in support by ASP.NET, which is very good. The bad thing about that, in my point of view, is that they are only doing it now, while most part of professional developers have been asking it for a long time.

Well, to see the post click here. Enjoy.

10 November 2007

Nero Scout

Just recently I found my computer freezing up with 100% used CPU due to the process NmIndexStoreSvr.exe.
It is not spyware or a virus, even though it damn well could be, as it does you more harm than good.

It's a sidekick utility of Nero Burner called "Nero Scout". This idiotic piece of software works by indexing all the media files on your computer so you don't have to browse for them when you want to use them with Nero.

These three are known processes of Nero Scout:
NmIndexStoreSvr.exe
NMBgMonitor.exe
NMFirstStart.exe


Here's how to disable this piece of junk on Nero Burner v. 7:
1. Open Nero Home
2. Open the options/configuration tab
3. Scroll down to, and click "Nero Scout"
4. Press the button "Configure Nero Scout"
5. Uncheck the "Activate Nero Scout" in the top left corner.

Reboot your computer. Voila!

If you still are experiencing problems after the reboot;

1. Click on the Start button and choose Run
2. Type the following line
regsvr32 /u "%COMMONPROGRAMFILES%\Ahead\Lib\MediaLibraryNSE.dll"
3. Click OK and reboot your PC.

09 November 2007

JavaScript support on VS 2008

There is a nice article about JavaScript support on Visual studio 2008.
Check here.

08 November 2007

Guitar Drifting

This is Andy Mckee. This video is already a classic on YouTube. Enjoy.

06 November 2007

My criminal career

VS 2008 will be Released in November

Microsoft releases Visual Studio 2008 this month. Check it here for the whole thing.
I can't wait :D

05 November 2007

Playing with LINQ

This is the second post about LINQ, and this time I'm doing it seriously.

As seen on the previous post, LINQ is one of the features of .NET Framework 3.5 which allows programmers to use query statements (such as select, join or where) on C# or VB.NET code. On this post I'll show how to use LINQ with a database and display data on a web UI.

I have created a simple database named BlogSampleLINQ with 4 tables: User, Post, Profile and Category. I know this isn't how a blog database should look like, but this is just a post for example purposes.



The next thing I have done was to create a new project on Web Developer 2008, named BlogSampleLINQ.


The first thing I have done on the project was to add a new Item, which is a LINQ to SQL class. This class type will allow me to do a simple drag-n-drop on my tables and turn them into objects; I'll no longer have to worry about the connection and everything. It will create a database conext object which will handle it all to me. Nice :D


Now that I have dragged the tables into LINQ to SQL designer, I can do some changes to my objects, such as property names, data types and everything. On this example, I'll just change the name of 2 properties and the rest will be default. The LINQ designer looks like this:



Now let's start coding. I have created a new class to perform the queries on my brand-new objects with LINQ and wrote the following code:


The code above has a join with tables User and Profile of my SampleBlogLINQ database. The database is represented by the object sample, which is an instance of the DataContext. It binds the actual database with the objects I have created when dragged the tables to the LINQ designer. Note that on the select clause, I'm selecting the Id and DisplayName properties of the object u (which is an instance of User) and I'm also selecting a property named Profile. Well, profile is the name of one of my tables (and one of my objects too), but in this case it doesn't represent the object. It's just an alias for the object p (which is an instance of Profile object). I could call this property anything, and it would work fine. Think of it as a pointer to the real object Profile.

After having the code done and compiled, I can go back to the asp.net design and start doing the UI. For this example I have added a GridView control and an ObjectDataSource control. On the ObjectDataSource I have chosen the the BlogUsers class as my business object.

And then I have chosen a method of my class to be the Select method of the ObjectDataSource. Then only thing left now is to configure the columns. On the grid view, click on smart tab and click Edit Column. Then uncheck the option "auto-generate fileds". Add two BoundFields and one TemplateField. For the two first columns edit the property "DataField" with the name of the corresponding property. For each field, edit the "HeaderText". You won't edit the template field on this box. Just click ok.

Now click again on the smart tab of the GridView, but this time choose the option Edit Templates.


It will show a box with a single Label control. This control is bound with the ObjectDataSource, so you can click on it's smart tag and select the (only) option Edit Databindings. This is the only "hard" part. You are gonna have to remember what the property and the child property names are. Then you're gonna type them on the expression on custom binding. On my case, my Select method is returning an AnonymusType which has 3 properties: Id(int), Name(string) and Profile(Profile). I want to display the profile name on this field, therefore, I'll have to use the expression Eval("Profile.Name"), coz the profile name is a property of the property Profile of my type.


And that's it. By pressing F5, my sample application will run and it will display the users and their profiles.

Well, needless to say, LINQ is one of the best things ever made (I'm talking about programming only, of course). It's one of the strongest parts of Framework 3.5 and, as shown here, very simple to use. I intend to explore this small database on the next posts with examples about LINQ.

Just one more thing. A friend of mine is linking on his blog the poster of .NET Framework 3.5 in PDF format. This poster shows the whole structure of the upcoming framework. Click here to get it.

04 November 2007

Starting with LINQ

Microsoft is about to release Visual Studio 2008 and .NET Framework 3.5; one of its greatest features is LINQ (which stands for Language-Integrated Query). This feature allows programmers to use query statements (select, where, join, etc) on .NET programming languages, such as C# and Visual Basic.


I have been trying Visual Web Developer 2008 Express Beta 2 (which you can download from here), and it seems good. As it's still beta, it's normal to see some things which still need a fix, particularly, I had a small problem with the properties windows, but nothing serious; just re-started the program and it worked fine. I haven't checked all the features yet. I’ve been playing around with LINQ and it seems really amazing, so I decided to write about it.


The basics of LINQ is to query arrays or collections of objects the same way we do to query a table in a database. Ok, it's obviously much more than that, but it's just a single post, not a fancy article. What I want to show here is how simple it is to use LINQ.


The code below shows how to perform a simple queriy with a custom object collections. Note that I have created a custom class named People which is just used to hold data, and another class named LinqSample1, which actually make the things happen. I have created an object named pplIKnow, which is a generic collection of People objects and I have populated it on the constructor of LinqSample1.


using System;
using System.Linq;
using System.Collections.Generic;


public class People {
public People() { }


public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public bool IsFriend { get; set; }
}

public class LinqSample1 {

private List<People> pplIKnow = new List<People>();

public LinqSample1() {
pplIKnow.Add(new People {
Id = 1, IsFriend = true,
FirstName = "Peter", LastName = "Parker"
});
pplIKnow.Add(new People {
Id = 2, IsFriend = false,
FirstName = "Tony", LastName = "Stark"
});
pplIKnow.Add(new People {
Id = 3, IsFriend = false,
FirstName = "Maria", LastName = "Hill"
});
pplIKnow.Add(new People {
Id = 4, IsFriend = true,
FirstName = "Hiro", LastName = "Nakamura"
});
pplIKnow.Add(new People {
Id = 5, IsFriend = true,
FirstName = "Jack", LastName = "Bauer"
});
}

public IEnumerable<People> ListFriends() {
var _result = from p in pplIKnow
where p.IsFriend
orderby p.LastName ascending
select p;

return _result;
}


public IEnumerable<People> ListEnemies() {
var _result = from p in pplIKnow
where !p.IsFriend
orderby p.LastName ascending
select p;

return _result;
}
}


I have added another two methods to my class, ListFriends and ListEnemies. And as you can see, it's really, really simple to perform the query. It's not the same as SQL queries once you have to filter, join and what ever prior select the columns you want, but still, it's that simple. I guess Mr. Anders Heijsberg has done his homework pretty well when he came up with LINQ.


Once you have a class or a class library which performs the queries, you can use their methods on the UI the same way we do with ASP.NET 2.0. Just as an example, I have created a webpage on my project and added two grid views to display the results of the methods I have on the class LinqSample1. Then I have added two ObjectDataSource objects, so this is how my web form looks like:


On the ObjectDataSources I have chosen class LinqSample1 as my business object and the corresponding methods to each GridView. Simple as that. On the next post about LINQ, I intend to go deeper on this subject because I really liked LINQ and I believe it's gonna be really helpful for everyone who programs in .NET. And please note that .NET Framework or Visual Studio 2008 haven't been officially released. They are still beta.

LINQ is a strong part of .NET Framework 3.5; it's really simple to use, even John create a program with it, and just to finish, the picture about is the application running.