Friday, May 21, 2010

Two new profile in new visual studio 2010.

Visual studio 2010 is a great tool and i have become fan of visual studio 2010. I have found two new code profile in visual studio 2010.

  1. Web Development Profile
  2. Web Development Code Optimized Profile.

Profile

Web Development profile will hide the top bar which contains the client object and and event dropdowns. So it will have more spaces.

WebDevelopment

Another one web development code optimized which will hide all the things except main windows. It will hide Toolbox,CSS properties and all other things so you will have more spaces to play with your html.

Windows Code Optimized

So as a web developer you can use this two great new profile as per your convenience when you only want to play with your html then use webdevelopement code optimized profile and another interesting thing is that you don’t have to reset your settings you can also just do with Tools->Settings menu like below. This will swap different profile like below.

Settigns

Hope this will help you..

Shout it
kick it on DotNetKicks.com
Share:
Thursday, May 20, 2010

Using transactions with LINQ-to-SQL

Today one of my colleague asked that how we can use transactions with the LINQ-to-SQL Classes when we use more then one entities updated at same time. It was a good question. Here is my answer for that.For ASP.NET 2.0 or higher version have a new class called TransactionScope which can be used to manage transaction with the LINQ.

Let’s take a simple scenario we are having a shopping cart application in which we are storing details or particular order placed into the database using LINQ-to-SQL. There are two tables Order and OrderDetails which will have all the information related to order. Order will store particular information about orders while OrderDetails table will have product and quantity of product for particular order.We need to insert data in both tables as same time and if any errors comes then it should rollback the transaction.

To use TransactionScope in above scenario first we have add a reference to System.Transactions like below.

TransactionScope,System.Transactions

After adding the transaction we need to drag and drop the Order and Order Details tables into Linq-To-SQL Classes it will create entities for that. Below is the code for transaction scope to use mange transaction with Linq Context.

 MyContextDataContext objContext = new MyContextDataContext();
using (System.Transactions.TransactionScope tScope
= new System.Transactions.TransactionScope(TransactionScopeOption.Required))
{
objContext.Order.InsertOnSubmit(Order);
objContext.OrderDetails.InsertOnSumbit(OrderDetails);
objContext.SubmitChanges();
tScope.Complete();
}
Here it will commit transaction only if using blocks will run successfully. Hope this will help you.

Shout it
kick it on DotNetKicks.com
Share:
Tuesday, May 18, 2010

Google Translation API Integration in .NET

Language localization is one of important thing of site of application nowadays. If you want your site or application more popular then other then it should support more then language. Some time it becomes difficult to translate all the sites into other languages so for i have found a great solution. Now you can use Google Translation API to translate your site or application dynamically. Here are steps you required to follow to integrate Google Translation API into Microsoft.NET Applications.

First you need download class library dlls from the following site.

http://code.google.com/p/google-language-api-for-dotnet/

Go this site and download GoogleTranslateAPI_0.1.zip.

Then once you have done that you need to add reference GoogleTranslateAPI.dll like following.

AddReference,Google,

Now you are ready to use the translation API from Google. Here is the code for that.

string Text = "This is a string to translate";
Console.WriteLine("Before Translation:{0}", Text);
Text=Google.API.Translate.Translator.Translate(Text,Google.API.Translate.Language.English,Google.API.Translate.Language.French);        
Console.WriteLine("Before Translation:{0}", Text);
That’s it it will return the string translated from English to French. But make you are connected to internet :)… Happy Programming

Technorati Tags: ,
Shout it
kick it on DotNetKicks.com
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews