Showing posts with label LINQ C# programming. Show all posts
Showing posts with label LINQ C# programming. Show all posts

Wednesday, January 21, 2009

Windows 7 SDK beta arrives

Last weekend, Microsoft unleashed the Windows 7 beta (take our in-depth tour) and the Windows Server 2008 R2 beta to the web. Due to the chaos and craze over downloading a beta operating system, many missed the news that Microsoft had also made the Windows 7 beta SDK available. If you're a developer, or you're just slightly interested, you can grab it from the Microsoft Download Center (1304.8MB). Here's what's on the .iso file:
The Windows SDK for Windows 7 and .NET Framework 3.5 SP1: BETA provides the documentation, samples, header files, libraries, and tools (including C++ compilers) that you need to develop applications to run on Windows 7 BETA and the .NET Framework 3.5 SP1. To build and run .NET Framework applications, you must have the corresponding version of the .NET Framework installed. This SDK is compatible with Visual Studio® 2008, including Visual Studio Express Editions, which are available free of charge.

If that got you interested, be sure to check out the Release Notes as well. The most important thing to note about this release is that the SDK will definitely change by the time Windows 7 is released, and developers should keep this in mind when they're using it. I would still recommend downloading it and getting a feel for what you'll want to update in your application to take advantage of the improvements of Vista's successor.

Read More...

Sunday, January 11, 2009

Tips on getting your ASP.NET Dynamic Data questions answered quickly

When you run into an issue or have a question about ASP.NET Dynamic Data, the best place for it is the Dynamic Data Forum. When you write your question, there are a few simple things that you can do to make it easier for the ‘experts’ to answer (and hence to get an answer quicker!).

1. Mention what ORM framework you are using
Out of the box, Dynamic Data supports LINQ To SQL and Entity Framework. While they seem similar on the surface, they are actually fairly different once you get a little deeper into the API. Just mention which one you’re using and you’ll save a roundtrip.

2. Mention what release you’re using
The official release of Dynamic Data is the one that comes with .NET Framework 3.5 SP1 (or Visual Studio 2008 SP1). There are also various preview bits and samples that you can download from Codeplex. Just mention exactly what you are using. If you’re using some preview bits, you can include a link to them to them to remove any ambiguity.

3. When possible, report issues using a standard database
Obviously, we don’t expect you to use Northwind or Adventure Works in your real project. But when you run into an issue with your custom schema, you should always check whether you are able to see the same thing with the standard DBs. Those DBs have schemas which contain many of the common patterns that you may be using. e.g. For One to Many relationship, you Northwind’s Product/Category, and for Many To Many, use Employees/Territories.

There are a few reasons why doing this is preferred. First, most readers are familiar with those schemas, so they can make sense of the situation quicker without having to analyze a custom schema. It also makes it a lot easier for people to try to reproduce the issue you’re seeing, since everyone has those sample databases. And finally, if the issue calls for a sample that demonstrates a workaround, using the standard DB, makes it much more useful to everyone else who runs into it.

Clearly, there are some situation where your custom schema is just different and using the standard DBs will not work. In those cases, just try to precisely describe your schema. Including a diagram can help too. In a nutshell, make sure that a reader not familiar with your database will understand enough of it to make sense of your question.

4. Try to isolate the issue

If an issue you see in a complex scenario can also be seen in a simpler scenario, it is always better to report it on the simpler scenario. It makes the question shorter and easier to read, as it keeps it focused on the essential.

5. Disable AJAX partial rendering
If you’re getting Javascript errors, the first thing you should try to to disable AJAX partial rendering. Please see this post for more details on this.

6. Include complete stack traces
If you’re getting an error in the browser, make sure you include the full stack trace that you see in there, and not just the text of the error. Looking through a stack trace can reveal some important clues about the issue.

Read MOre...

Friday, January 9, 2009

Mount Remote FTP And Webdav Servers

NetDrive is a software to mount remote ftp and webdav servers that somehow has never been mentioned at Ghacks before. That’s a rare occurrence especially if the software is well designed and free. A large portion of webmasters have to connect to remote ftp servers regularly to update files on the website. There are obviously other ways to update files like an admin interface that allows the direct manipulation of files on the server.

An alternative to connecting to remote ftp servers with ftp programs is to mount the ftp server as a local drive on the computer system. NetDrive provides the means to do that.

The software comes with a clean interface that has several popular ftp servers preinstalled. New servers can be added by providing the IP, port, username, password and drive letter for that connection. There is also a setting to define when the ftp server or webdav server should be added as a drive letter. The options are to do that when the system starts or when NetDrive starts.

Read More..

Tuesday, January 6, 2009

Hidden Features in C#

1) Using @ for variable that are keyword.

var @object = new object();
var @string = "";
var @if = IpsoFacto();

2) Aliased Generics.

using ASimpleName = Dictionary>>;


Allows you to ASimpleName,instead of

Dictionary>>;

Use it when you would use the same generic big long complex thing in a lot of places.

Read MOre..

Thursday, December 18, 2008

Beep in C# Console Application

How to Alert the user in C# console application

You can use “\a” to alert the user with the system beep sound. The following example alerts the user for input

private static void KeywordExample()

{

Console.Write("\a Your name please" );

string @MyString = Console.ReadLine();

Console.Write(@MyString);

}

Read more..

Monday, November 24, 2008

C++ enhancements in VS 2010

As part of my series of blog posts talking about VS 2010 and .NET FX 4, I want to focus on the work we are doing for the native developer as part of Visual C++.

In an earlier post, I mentioned how the Visual C++ team is investing heavily in enabling developers with large native applications to be successful on the Windows platform. As a part of that, we released the Visual C++ 2008 Feature Pack earlier this year. Visual Studio 2010 continues down this path by focusing on making native C++ developers more productive with significant enhancements to the overall IDE experience as well as improvements in the language and library space that further extend the power available to C++ developers.

Native C++ applications have been growing larger and more complex over the years. VS2010 makes C++ developers more productive by scaling better when working with larger codebases. One of the key areas where we are making significant improvements is IntelliSense. The IntelliSense engine, which powers the majority of the IDE features, received a major architectural overhaul with a sharp focus on eliminating inefficiencies that surface when dealing with large codebases. A prime example of this is that the IDE remains responsive even while editing source files in very large codebases. Source edits no longer trigger massive updates of the symbol database even with the most complex source dependencies. Visual C++ developers who often edit header files deep down in the include hierarchy or switch project configurations will notice the huge improvement in IDE responsiveness.

Read More...

Sunday, November 2, 2008

LINQ - C# Programming

Get DataSource
In C# as in most programming languages a variable must be declared before it can be used. In a LINQ query, the from clause comes first in order to introduce the data source (customers) and the range variable (cust).

//QEmp is an IEnumerable
var QEmp = from e in Emp
select e;

Filter

Probably the most common query operation is to apply a filter in the form of a Boolean expression. The filter causes the query to return only those elements for which the expression is true. The result is produced by using the where clause. The filter in effect specifies which elements to exclude from the source sequence.

var QEmp = from e in Emp
where e.Country == "India"
select e

----AND Condition----
where e.Country == "India" && e.Name == "Ashvin"

----OR Condition----
where e.Country == "India" || e.Name == "Ashvin"

Ordering
The orderby clause will cause the elements in the returned sequence to be sorted according to the default comparer for the type being sorted. For example, the following query can be extended to sort the results based on the Name property. Because Name is a string, the default comparer performs an alphabetical sort from A to Z.
var QEmp = from e in Emp
where e.Country == "India"
orderby e.Name ascending
select e


Read More...