public bool SetPermissions(string remoteDir, string MachineName, string UserName, string Password) // Username and Password is of Admin account on remote machine
{
string TempName = remoteDir;
int Index = TempName.IndexOf(":");
string DriveLetter = ConfigurationManager.AppSettings["ShareDriveLetter"]; // e.q. C
if (Index != -1)
{
string[] arr = TempName.Split(new char[] { ':' });
DriveLetter = arr[0];
TempName = TempName.Substring(Index + 2);
}
ManagementPath myPath = new ManagementPath();
myPath.NamespacePath = @"root\CIMV2";
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = UserName;
oConn.Password = Password;
oConn.EnablePrivileges = true;
myPath.Server = MachineName;
ManagementScope scope = new ManagementScope(myPath, oConn);
scope.Connect();
//without next strange manipulation, the os.Get().Count will throw the "Invalid query" exception
remoteDir = remoteDir.Replace("\\", "\\\\");
ObjectQuery oq = new ObjectQuery("select Name from Win32_Directory where Name = '" + remoteDir + "'");
using (ManagementObjectSearcher os = new ManagementObjectSearcher(scope, oq))
{
if (os.Get().Count == 0) //It don't exist, so create it!
{
ManagementPath path2 = new ManagementPath();
path2.Server = MachineName;
path2.ClassName = "Win32_Process";
path2.NamespacePath = @"root\CIMV2";
ManagementScope scopeProcess = new ManagementScope(path2, oConn);
using (ManagementClass process = new ManagementClass(scopeProcess, path2, null))
{
//Command line that you want to execute on remote machine
string commandLine = @"cmd /C cacls " + TempName +" /C /T /E /P "+"0909020:F"; // 0909020:F is username:permissions
using (ManagementBaseObject inParams = process.GetMethodParameters("Create"))
{
inParams["CommandLine"] = commandLine;
inParams["CurrentDirectory"] = DriveLetter + @":\\";
inParams["ProcessStartupInformation"] = null;
using (ManagementBaseObject outParams = process.InvokeMethod("Create", inParams, null))
{
int retVal = Convert.ToInt32(outParams.Properties["ReturnValue"].Value);
return (retVal == 0);
}
}
}
}
else
{
return true;//if exists, return true; you may want to return false, of course
}
}
return false;
}
20 November 2009
Set NTFS folder permissions on remote machine using .NET and WMI
After considerable amount of efforts and trial I was finally able to hack the solution to set NTFS permissions on a remote machine using .NET. For local file system it is just couple of line of codes and it works like a charm but when it comes to remote machines it just gives you a nightmare . So here goes my solution. I am sure this will help someone.
08 October 2009
Microsoft launches Windows smartphones : My view on it
Microsoft is in a battle to reincarnate its dinosaur mobile OS with launch of its own smartphone.The phones, which combine the ability to make calls, surf the internet and view videos, carry Microsoft's Windows Mobile 6.5 operating system.I know you will go like Hey don't we already have that. Don't you think it is too little too late !!! The smartphone market is already saturated with lots of different OS and the major ones like Apple's iPhone system, Plam OS, Google's Android (which is a free platform) and Symbian OS. The new venture Microsoft is attempting is just a desperation to gain market that it already lost to big guys like Google and Apple. In a official launch Mr. Ballmer said "We have taken the Internet Explorer browser technologies, and we rebuilt them for the first time for these Windows phones. So you can get the same experience on these phones that you will get on your windows PC." (Hey watch out, The Blue Screen Of Death (BSOD) is coming to your smartphones !!!) Is that the way you promote your technology. A reincarnated IE ??? Lets face it IE is no where near the facilities provided by other browsers like Mozilla Firefox and with the new kid on the block called Crome which is improving at a speed of light (Well that is an exaggeration but you know what I mean !!!). Microsoft needs to come up with something new that is authentic and that can make others to follow it rather than just trying to get the market that is already saturated. Get a life Microsoft and you really needs some great minds to think of products Mr. Ballmer !!!
03 October 2009
Google Wave: What is it ?
There is a new Google product called Google Wave currently under limited preview. Some of you may have already tried it or at least looked at its video or you may not have any idea about whatsoever. In a simple term it a mashup of emails,documents and social networking. Don't scratch your head. Just go to google and google it! (How ironic !!!). You can look at a video on youtube that explains it in a simple terms. and if you want to get a detailed explanation of it go to Google Wave's website and spare yourself an hour of amazement.
Here is a simple explanation of what you can do with google wave.
For Example you want to know more about Sydeny Opera House. So you start a new wave with this topic and invite your friends. Once they join the wave they can comment on it and everyone who are in the wave can view it and provide their opinion. You will go so whats a big deal here ? You can also share photographs and documents. It can be a really good collaboration platform.
So head out to Google Wave and enjoy it.
30 May 2009
Microsoft's Bing search engine comming soon
Did you heard the news ? What news ? Hey don't worry its not new development in Swine Flue pandemic ! Microsoft is launching its new search engine. You will say don't they have one called "Live". "May be its time for Live to be dead and get reincarnation as a Bing." The reason they are coming up with new search engine is the Live search is not giving them revenue they are expecting and Google is dominating the search engine market and certainly making its more than 90% revenue out of it. So the big guy (Microsoft) want big chunk of the pie rather then just a piece.
Microsoft CEO Steve Ballmer in San Diego during D7 Conference officially launched its new search engine called Bing that previously code named as "Kumo". Microsoft is calling it a decision engine rather than a search engine. Hey don't worry it gives you the search result only not the decision on what to eat today !!!
I have a look at its video and first impression was really awesome.I am not exaggerating.Check out its video Here . You can get more information on Bing Here.
It may be the time for Google to worry a bit. Well it takes a really big effort to get people to use new search engine. "Google become more of a verb than a noun in last decade." Google will certainly reply back to Bing with whatever it takes to sustain its position. Microsoft is also launching $80 to $100 million advertising campaign to promote Bing. By the time, lets enjoy this new battle as it progress and get the most out of it.
17 May 2009
Google's new features : Wonder wheel
Hey, Did anyone noticed Google's new feature when you search something. It gives you more control over your search query. You can see the hyperlink came up when you search something called Show options.... You click on it and magic happens.... well you will say what is new with that options panel. But as you can notice it allows you to filter your result with regards to the time articles published, if you want to see only videos or forums or reviews and there is something very special called wonder wheel. You click on it and it gives you the options to further refine your result. It is really cool.!!!
For example you search for car dealers in sydney and click on the wonder wheel and it automatically refine your search result and allow you to pick up options to go for particular area in sydney and when you choose something it further gives you the options to choose type of car you want. I find it really cool and I am sure you will also enjoy it. Though it is a good option for end users it is a pain in ass for Search Engine Optimization (SEO) guys as they have to take into account this new feature and try to rank their websites for all possible keywords. It will certainly take time for people to get used to with this new feature and use it more frequently and by that time SEO guys needs to come up with solutions to fool this wonder wheel. I hope they will find out something very soon otherwise they are in trouble.
By the time enjoy coffee... and think of ideas.....
10 May 2009
Serialization in .NET
This article is about serialization facility in .NET framework and particularly Object Serialization. So lets start from scratch and define first what is serialization ?
Serialization is the process of storing objects to the file or isolated file and later use it in the same application or same process or in another application on remote machine. It is just like you store data to a file and later use it in another application or same application. The difference here is you are storing objects not some random data and later recreate same object via deserialization.
This process is made simple via .NET frameworks serialization classes. The namespace we are looking here is System.Runtime.Serialization. Serialization save a lot of development time. There are three different kind of serialization provided by .NET framework.
1. Object Serialization
2. XML Serialization
3. Custom Serialization
In this article we will look at Object Serialization.
To serialize an object is very simple process.
1. Create a stream object that can hold the serialized object.
2. Create a BinaryFormatter object (namespace System.Runtime.Serialization.Formatters.Binary).
3. Call BinaryFormatter.Serialize method to serialize the object and output it to a stream.
Lets see it in example. I use C# as a programming language here.
// string object data that is to be serialized.
string data = "This data is to be serialized";
// Create a file stream to save data.
FileStream fs = new FileStream("mySerialiedData.dat",FileMode.Create);
//Create BinaryFormatter object
BinaryFormatter bf = new BinaryFormatter();
// use bf object to serialize data.
bf.Serialize(fs,data);
//close file stream
fs.Close();
That's it the data object is serialized and stored in file mySerializedData.dat.
You can deserialize it using BinaryFormatter's Deserialize method. You need to cast the object back to proper data type.
FileStream fs = new FileStream("mySerializedData.dat",FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
string data = (string) bf.Deserialize(fs); // cast it back to string object
fs.close();
You can serialize and deserialize any object using same technique.
You can make the custom class Serializable and Deserializable by using [Serializable] attribute.
For example:
[serializable]
class Product
{
public int id;
public string name;
public float price;
public double tax;
}
If tax is calculated using value of price than there is no need to serialize it to reduce the size of serialized object. To do this declare it as a [NonSerialized] attribute and implement IDeserializationCallback interface to calculate it when deserializing the object.
For example:
[serializable]
class Product : IDeSerializationCallback
{
public int id;
public string name;
public float price;
[NonSerialized]public double tax;
void IDeserializationCallback.OnDeserialization(object sender)
{
tax = price*0.1;
}
}
Now the value of tax will be available to the application that deserialize the object of Product class via OnDeserializing callback method.
This is how the serialization works in .NET environment. Isn't it really simple? So enjoy serializing. And by the way the closest resemblance to serialization is the teleportation in science fiction !
Serialization is the process of storing objects to the file or isolated file and later use it in the same application or same process or in another application on remote machine. It is just like you store data to a file and later use it in another application or same application. The difference here is you are storing objects not some random data and later recreate same object via deserialization.
This process is made simple via .NET frameworks serialization classes. The namespace we are looking here is System.Runtime.Serialization. Serialization save a lot of development time. There are three different kind of serialization provided by .NET framework.
1. Object Serialization
2. XML Serialization
3. Custom Serialization
In this article we will look at Object Serialization.
To serialize an object is very simple process.
1. Create a stream object that can hold the serialized object.
2. Create a BinaryFormatter object (namespace System.Runtime.Serialization.Formatters.Binary).
3. Call BinaryFormatter.Serialize method to serialize the object and output it to a stream.
Lets see it in example. I use C# as a programming language here.
// string object data that is to be serialized.
string data = "This data is to be serialized";
// Create a file stream to save data.
FileStream fs = new FileStream("mySerialiedData.dat",FileMode.Create);
//Create BinaryFormatter object
BinaryFormatter bf = new BinaryFormatter();
// use bf object to serialize data.
bf.Serialize(fs,data);
//close file stream
fs.Close();
That's it the data object is serialized and stored in file mySerializedData.dat.
You can deserialize it using BinaryFormatter's Deserialize method. You need to cast the object back to proper data type.
FileStream fs = new FileStream("mySerializedData.dat",FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
string data = (string) bf.Deserialize(fs); // cast it back to string object
fs.close();
You can serialize and deserialize any object using same technique.
You can make the custom class Serializable and Deserializable by using [Serializable] attribute.
For example:
[serializable]
class Product
{
public int id;
public string name;
public float price;
public double tax;
}
If tax is calculated using value of price than there is no need to serialize it to reduce the size of serialized object. To do this declare it as a [NonSerialized] attribute and implement IDeserializationCallback interface to calculate it when deserializing the object.
For example:
[serializable]
class Product : IDeSerializationCallback
{
public int id;
public string name;
public float price;
[NonSerialized]public double tax;
void IDeserializationCallback.OnDeserialization(object sender)
{
tax = price*0.1;
}
}
Now the value of tax will be available to the application that deserialize the object of Product class via OnDeserializing callback method.
This is how the serialization works in .NET environment. Isn't it really simple? So enjoy serializing. And by the way the closest resemblance to serialization is the teleportation in science fiction !
06 May 2009
Windows 7 Release Candidate
Hi All,
Watch out !!! Windows 7 is on its way. Release Candidate is available for download now. Though its not final version yet RC is more close to the final version. Those who may have used beta or wants to check whats new can download it from Microsoft Windows 7 official website. Have a look at the systems requirements.
A PC for testing that meets these minimum system requirements (specific to Windows 7 RC and subject to change in the final version of Windows 7):
*1 GHz or faster 32-bit (x86) or 64-bit (x64) processor
*1 GB RAM (32-bit) / 2 GB RAM (64-bit)
*16 GB available disk space (32-bit) / 20 GB (64-bit)
*DirectX 9 graphics processor with WDDM 1.0 or higher driver
One thing is sure it is going to be the big installation. So those who are using XP on old systems might be disappointed. And one advise those who are buying PC or Notebook at the moment. Wait for a while or ask your dealer if you can get the free upgrade to Windows 7 in future.
Watch out !!! Windows 7 is on its way. Release Candidate is available for download now. Though its not final version yet RC is more close to the final version. Those who may have used beta or wants to check whats new can download it from Microsoft Windows 7 official website. Have a look at the systems requirements.
A PC for testing that meets these minimum system requirements (specific to Windows 7 RC and subject to change in the final version of Windows 7):
*1 GHz or faster 32-bit (x86) or 64-bit (x64) processor
*1 GB RAM (32-bit) / 2 GB RAM (64-bit)
*16 GB available disk space (32-bit) / 20 GB (64-bit)
*DirectX 9 graphics processor with WDDM 1.0 or higher driver
One thing is sure it is going to be the big installation. So those who are using XP on old systems might be disappointed. And one advise those who are buying PC or Notebook at the moment. Wait for a while or ask your dealer if you can get the free upgrade to Windows 7 in future.
21 April 2009
Oracle to buyout Sun Microsystems
Yesterday Oracle Corporation formally announced its intention to buy Sun Microsystems. This is bit of a shock news for me and sure for lot of those who follow Sun closely. Hey my concern is not about dog eat dog situation here. The big question that concern me is that Is it the end of open source era? I hope certainly not. As Sun Microsystems is the biggest Open Source solutions and products provider and lots of penetration in the market this potential take our will create big concern in the market. Lets See how this goes as the Oracle still have to overcome stakeholders approval of this big transaction. Can Oracle really be the Oracle (the one that can see in future) and snatch the deal? You can read the story on Oracle Press release.
05 April 2009
Windows: Create Naameless Folder and Files
This is a fun!!! Lets Create Nameless Folder or File.
1.Select any file or folder or create new one.
2.Right click on it, press rename or simply press F2.
3.Press and hold the alt key. While holding the Alt key, type numbers 0160 from the numpad.
Note: Type the numbers 0160 from the numpad, that is, the numbers present on the right side of the keyboard. Don't type the numbers which are present on top of the character keys. Notebook users first click on numlock key to use this feature.
4. Press Enter and the nameless file or folder will be created.
What is the rational behind it?
The file or folder that seems nameless is actually named with a single space.
But what if you want to create another nameless file or folder in the same directory?
For this you will have to rename the file with 2 spaces. Just follow these steps below:
1.Select file, press F2.
2.Hold alt key and type 0160 from the numpad.
3.Release the alt key. Now without doing anything else, again hold alt key and press 0160.
4.Press enter and you will have second nameless file in the same directory.
5.Repeat step 3 to create as many nameless files or folders in the same directory.
1.Select any file or folder or create new one.
2.Right click on it, press rename or simply press F2.
3.Press and hold the alt key. While holding the Alt key, type numbers 0160 from the numpad.
Note: Type the numbers 0160 from the numpad, that is, the numbers present on the right side of the keyboard. Don't type the numbers which are present on top of the character keys. Notebook users first click on numlock key to use this feature.
4. Press Enter and the nameless file or folder will be created.
What is the rational behind it?
The file or folder that seems nameless is actually named with a single space.
But what if you want to create another nameless file or folder in the same directory?
For this you will have to rename the file with 2 spaces. Just follow these steps below:
1.Select file, press F2.
2.Hold alt key and type 0160 from the numpad.
3.Release the alt key. Now without doing anything else, again hold alt key and press 0160.
4.Press enter and you will have second nameless file in the same directory.
5.Repeat step 3 to create as many nameless files or folders in the same directory.
Windows XP : Some useful and intersting commands
These are some useful and interesting Windows XP commands you may want to use. I compiled a list of commands that you may find interesting. So just go to Start menu and click Run... and type following commands to see yourself what they do....
#SQL Client Configuration - cliconfg
#System Configuration Editor - sysedit
#System Configuration Utility - msconfig
#System File Checker Utility (Scan Immediately)- sfc /scannow
#System File Checker Utility (Scan Once At Next Boot)- sfc /scanonce
#System File Checker Utility (Scan On Every Boot) - sfc /scanboot
#System File Checker Utility (Return to Default Setting)- sfc /revert
#System File Checker Utility (Purge File Cache)- sfc /purgecache
#System File Checker Utility (Set Cache Size to size x)-sfc/cachesize=x
#System Information - msinfo32.
#Task Manager – taskmgr
#System Properties - sysdm.cpl
#Task Manager – taskmgr
#TCP Tester - tcptest
#Telnet Client - telnet
#Tweak UI (if installed) - tweakui
#User Account Management- nusrmgr.cpl
#Utility Manager - utilman
#Windows Address Book - wab
#Windows Address Book Import Utility - wabmig
#Windows Backup Utility (if installed)- ntbackup
#Windows Explorer - explorer
#Windows Firewall- firewall.cpl
#Windows Magnifier- magnify
#Windows Management Infrastructure - wmimgmt.msc
#Windows Media Player - wmplayer
#Windows Messenger - msmsgs
#Windows Picture Import Wizard (need camera connected)- wiaacmgr
#Windows System Security Tool – syskey
#Windows Update Launches - wupdmgr
#Windows Version (to show which version of windows)- winver
#Windows XP Tour Wizard - tourstart
#Wordpad - write
#Password Properties - password.cpl
#Performance Monitor - perfmon.msc
#Phone and Modem Options - telephon.cpl
#Phone Dialer - dialer
#Pinball Game - pinball
#Power Configuration - powercfg.cpl
#Printers and Faxes - control printers
#Printers Folder – printers
#Private Character Editor - eudcedit
#Quicktime (If Installed)- QuickTime.cpl
#Real Player (if installed)- realplay
#Regional Settings - intl.cpl
#Registry Editor - regedit
#Registry Editor - regedit32
#Remote Access Phonebook - rasphone
#Remote Desktop - mstsc
#Removable Storage - ntmsmgr.msc
#Removable Storage Operator Requests - ntmsoprq.msc
#Resultant Set of Policy (XP Prof) - rsop.msc
#Scanners and Cameras - sticpl.cpl
#Scheduled Tasks - control schedtasks
#Security Center - wscui.cpl
#Services - services.msc
#Shared Folders - fsmgmt.msc
#Shuts Down Windows - shutdown
#Sounds and Audio - mmsys.cpl
#Spider Solitare Card Game - spider
#Malicious Software Removal Tool - mrt
#Microsoft Access (if installed) - access.cpl
#Microsoft Chat - winchat
#Microsoft Excel (if installed) - excel
#Microsoft Frontpage (if installed)- frontpg
#Microsoft Movie Maker - moviemk
#Microsoft Paint - mspaint
#Microsoft Powerpoint (if installed)- powerpnt
#Microsoft Word (if installed)- winword
#Microsoft Syncronization Tool - mobsync
#Minesweeper Game - winmine
#Mouse Properties - control mouse
#Mouse Properties - main.cpl
#Nero (if installed)- nero
#Netmeeting - conf
#Network Connections - control netconnections
#Network Connections - ncpa.cpl
#Network Setup Wizard - netsetup.cpl
#Notepad - notepad
#Nview Desktop Manager (If Installed)- nvtuicpl.cpl
#Object Packager - packager
#ODBC Data Source Administrator- odbccp32.cpl
#On Screen Keyboard - osk
#Opens AC3 Filter (If Installed) - ac3filter.cpl
#Outlook Express - msimn
#Paint – pbrush
#Keyboard Properties - control keyboard
#IP Configuration (Display Connection Configuration) - ipconfi/all
#IP Configuration (Display DNS Cache Contents)- ipconfig /displaydns
#IP Configuration (Delete DNS Cache Contents)- ipconfig /flushdns
#IP Configuration (Release All Connections)- ipconfig /release
#IP Configuration (Renew All Connections)- ipconfig /renew
#IP Configuration(RefreshesDHCP&Re-RegistersDNS)-ipconfig/registerdns
#IP Configuration (Display DHCP Class ID)- ipconfig/showclassid
#IP Configuration (Modifies DHCP Class ID)- ipconfig /setclassid
#Java Control Panel (If Installed)- jpicpl32.cpl
#Java Control Panel (If Installed)- javaws
#Local Security Settings - secpol.msc
#Local Users and Groups - lusrmgr.msc
#Logs You Out Of Windows - logoff.....
#Accessibility Controls - access.cpl
#Accessibility Wizard - accwiz
#Add Hardware - Wizardhdwwiz.cpl
#Add/Remove Programs - appwiz.cpl
#Administrative Tools control - admintools
#Adobe Acrobat (if installed) - acrobat
#Adobe Designer (if installed)- acrodist
#Adobe Distiller (if installed)- acrodist
#Adobe ImageReady (if installed)- imageready
#Adobe Photoshop (if installed)- photoshop
#Automatic Updates - wuaucpl.cpl
#Bluetooth Transfer Wizard – fsquirt
#Calculator - calc
#Certificate Manager - certmgr.msc
#Character Map - charmap
#Check Disk Utility - chkdsk
#Clipboard Viewer - clipbrd
#Command Prompt - cmd
#Component Services - dcomcnfg
#Computer Management - compmgmt.msc
#Control Panel - control
#Date and Time Properties - timedate.cpl
#DDE Shares - ddeshare
#Device Manager - devmgmt.msc
#Direct X Control Panel (If Installed)- directx.cpl
#Direct X Troubleshooter- dxdiag
#Disk Cleanup Utility- cleanmgr
#Disk Defragment- dfrg.msc
#Disk Management- diskmgmt.msc
#Disk Partition Manager- diskpart
#Display Properties- control desktop
#Display Properties- desk.cpl
#Display Properties (w/Appearance Tab Preselected)- control color
#Dr. Watson System Troubleshooting Utility- drwtsn32
#Driver Verifier Utility- verifier
#Event Viewer- eventvwr.msc
#Files and Settings Transfer Tool- migwiz
#File Signature Verification Tool- sigverif
#Findfast- findfast.cpl
#Firefox (if installed)- firefox
#Folders Properties- control folders
#Fonts- control fonts
#Fonts Folder- fonts
#Free Cell Card Game- freecell
#Game Controllers- joy.cpl
#Group Policy Editor (XP Prof)- gpedit.msc
#Hearts Card Game- mshearts
#Help and Support- helpctr
#HyperTerminal- hypertrm
#Iexpress Wizard- iexpress
#Indexing Service- ciadv.msc
#Internet Connection Wizard- icwconn1
#Internet Explorer- iexplore
#Internet Setup Wizard- inetwiz
#Internet Properties- inetcpl.cpl
#SQL Client Configuration - cliconfg
#System Configuration Editor - sysedit
#System Configuration Utility - msconfig
#System File Checker Utility (Scan Immediately)- sfc /scannow
#System File Checker Utility (Scan Once At Next Boot)- sfc /scanonce
#System File Checker Utility (Scan On Every Boot) - sfc /scanboot
#System File Checker Utility (Return to Default Setting)- sfc /revert
#System File Checker Utility (Purge File Cache)- sfc /purgecache
#System File Checker Utility (Set Cache Size to size x)-sfc/cachesize=x
#System Information - msinfo32.
#Task Manager – taskmgr
#System Properties - sysdm.cpl
#Task Manager – taskmgr
#TCP Tester - tcptest
#Telnet Client - telnet
#Tweak UI (if installed) - tweakui
#User Account Management- nusrmgr.cpl
#Utility Manager - utilman
#Windows Address Book - wab
#Windows Address Book Import Utility - wabmig
#Windows Backup Utility (if installed)- ntbackup
#Windows Explorer - explorer
#Windows Firewall- firewall.cpl
#Windows Magnifier- magnify
#Windows Management Infrastructure - wmimgmt.msc
#Windows Media Player - wmplayer
#Windows Messenger - msmsgs
#Windows Picture Import Wizard (need camera connected)- wiaacmgr
#Windows System Security Tool – syskey
#Windows Update Launches - wupdmgr
#Windows Version (to show which version of windows)- winver
#Windows XP Tour Wizard - tourstart
#Wordpad - write
#Password Properties - password.cpl
#Performance Monitor - perfmon.msc
#Phone and Modem Options - telephon.cpl
#Phone Dialer - dialer
#Pinball Game - pinball
#Power Configuration - powercfg.cpl
#Printers and Faxes - control printers
#Printers Folder – printers
#Private Character Editor - eudcedit
#Quicktime (If Installed)- QuickTime.cpl
#Real Player (if installed)- realplay
#Regional Settings - intl.cpl
#Registry Editor - regedit
#Registry Editor - regedit32
#Remote Access Phonebook - rasphone
#Remote Desktop - mstsc
#Removable Storage - ntmsmgr.msc
#Removable Storage Operator Requests - ntmsoprq.msc
#Resultant Set of Policy (XP Prof) - rsop.msc
#Scanners and Cameras - sticpl.cpl
#Scheduled Tasks - control schedtasks
#Security Center - wscui.cpl
#Services - services.msc
#Shared Folders - fsmgmt.msc
#Shuts Down Windows - shutdown
#Sounds and Audio - mmsys.cpl
#Spider Solitare Card Game - spider
#Malicious Software Removal Tool - mrt
#Microsoft Access (if installed) - access.cpl
#Microsoft Chat - winchat
#Microsoft Excel (if installed) - excel
#Microsoft Frontpage (if installed)- frontpg
#Microsoft Movie Maker - moviemk
#Microsoft Paint - mspaint
#Microsoft Powerpoint (if installed)- powerpnt
#Microsoft Word (if installed)- winword
#Microsoft Syncronization Tool - mobsync
#Minesweeper Game - winmine
#Mouse Properties - control mouse
#Mouse Properties - main.cpl
#Nero (if installed)- nero
#Netmeeting - conf
#Network Connections - control netconnections
#Network Connections - ncpa.cpl
#Network Setup Wizard - netsetup.cpl
#Notepad - notepad
#Nview Desktop Manager (If Installed)- nvtuicpl.cpl
#Object Packager - packager
#ODBC Data Source Administrator- odbccp32.cpl
#On Screen Keyboard - osk
#Opens AC3 Filter (If Installed) - ac3filter.cpl
#Outlook Express - msimn
#Paint – pbrush
#Keyboard Properties - control keyboard
#IP Configuration (Display Connection Configuration) - ipconfi/all
#IP Configuration (Display DNS Cache Contents)- ipconfig /displaydns
#IP Configuration (Delete DNS Cache Contents)- ipconfig /flushdns
#IP Configuration (Release All Connections)- ipconfig /release
#IP Configuration (Renew All Connections)- ipconfig /renew
#IP Configuration(RefreshesDHCP&Re-RegistersDNS)-ipconfig/registerdns
#IP Configuration (Display DHCP Class ID)- ipconfig/showclassid
#IP Configuration (Modifies DHCP Class ID)- ipconfig /setclassid
#Java Control Panel (If Installed)- jpicpl32.cpl
#Java Control Panel (If Installed)- javaws
#Local Security Settings - secpol.msc
#Local Users and Groups - lusrmgr.msc
#Logs You Out Of Windows - logoff.....
#Accessibility Controls - access.cpl
#Accessibility Wizard - accwiz
#Add Hardware - Wizardhdwwiz.cpl
#Add/Remove Programs - appwiz.cpl
#Administrative Tools control - admintools
#Adobe Acrobat (if installed) - acrobat
#Adobe Designer (if installed)- acrodist
#Adobe Distiller (if installed)- acrodist
#Adobe ImageReady (if installed)- imageready
#Adobe Photoshop (if installed)- photoshop
#Automatic Updates - wuaucpl.cpl
#Bluetooth Transfer Wizard – fsquirt
#Calculator - calc
#Certificate Manager - certmgr.msc
#Character Map - charmap
#Check Disk Utility - chkdsk
#Clipboard Viewer - clipbrd
#Command Prompt - cmd
#Component Services - dcomcnfg
#Computer Management - compmgmt.msc
#Control Panel - control
#Date and Time Properties - timedate.cpl
#DDE Shares - ddeshare
#Device Manager - devmgmt.msc
#Direct X Control Panel (If Installed)- directx.cpl
#Direct X Troubleshooter- dxdiag
#Disk Cleanup Utility- cleanmgr
#Disk Defragment- dfrg.msc
#Disk Management- diskmgmt.msc
#Disk Partition Manager- diskpart
#Display Properties- control desktop
#Display Properties- desk.cpl
#Display Properties (w/Appearance Tab Preselected)- control color
#Dr. Watson System Troubleshooting Utility- drwtsn32
#Driver Verifier Utility- verifier
#Event Viewer- eventvwr.msc
#Files and Settings Transfer Tool- migwiz
#File Signature Verification Tool- sigverif
#Findfast- findfast.cpl
#Firefox (if installed)- firefox
#Folders Properties- control folders
#Fonts- control fonts
#Fonts Folder- fonts
#Free Cell Card Game- freecell
#Game Controllers- joy.cpl
#Group Policy Editor (XP Prof)- gpedit.msc
#Hearts Card Game- mshearts
#Help and Support- helpctr
#HyperTerminal- hypertrm
#Iexpress Wizard- iexpress
#Indexing Service- ciadv.msc
#Internet Connection Wizard- icwconn1
#Internet Explorer- iexplore
#Internet Setup Wizard- inetwiz
#Internet Properties- inetcpl.cpl
02 February 2009
Rubic cube 360 : coming soon
Do you folks love Rubic cube ? Some geek will say whats new with that freaking square... It eat half of my time i should have done something else. An interesting bit for someone who don't know anything about Rubic cube!!! The Cube was an instant success when it was first exported from Communist Hungary in 1980, becoming the world’s fastest-selling toy and a must-have accessory in the school playground as well as the home.More than 350 million have been sold worldwide and the Cube retains a cult following, with almost 40,000 entries on YouTube featuring tutorials and video clips of quick solutions. It took Graham Parker a notorious Rubic cube lover 26 years to solve a single puzzle !!! I know now you will scream "What The F***?". Anyways there is a good (and indeed bad for some) news that the puzzle got reincarnation. New version of Rubic Cube is coming soon called Rubic 360. The new puzzle, called Rubik 360, is set for an official unveiling at the German toy industry fair on February 5. Like the original, the premise is simple.Oh no! Another 26 years!!! May be. There are two spheres and inner one contain colored balls and there are only two holes in it and player must get all colored balls to its corresponding outer sphere matching circle. Sounds simple so does the original.
RUBIK’S CUBE FACTS
* It has 43,252,003,274,489,856,000 possible combinations on its six faces
* It has only one solution
* More than 350,000,000 Cubes sold worldwide
* Invented in 1974 but not exported from Hungary until 1980
* A standard 3x3 Rubik’s cube measures 2¼ inches (5.7cm) on each side
* The first international 'speedcubing’ championship was held in Hungary in 1982 and was won by Los Angeles student Minh Thai with a time of 22.95 seconds.
* The current British 'speedcubing’ champion is Breandan McElhill, 16, from Ayrshire with an unofficial personal best time of 7.9 seconds.
* The current world 'speedcubing’ champion is Dutch teenager Eric Akkersdijk with an official time of 7.08 seconds.
23 January 2009
Solid State Drives : Slowly making its way
First of all I would like to go bake to 80's and show you a picture and guess what its a hard drive!!! And size? massive 5 MB !!! I am sure you will laugh at it now. We have TBs of HDD in our notebooks nowadays. But its only problem is it has a mechanical head that runs at 4200 to 7200 rmp. It is like a jet engine. So what? It is vulnerable to fail if you drops it and it consumes more power. It is a mechanical HDD at the end of the day. Though the technology is improved enormously and there are many protective measures to prevent it from failing we certainly need something that can replace it in the future for better performance and low power consumption. As long as you have desktop you don't bother much about power consumption but as soon as you move to notebooks you started to think how can I make my notebook run for longer without charging its battery. There comes the SSDs in picture. In simple terminology it is just like a flash drive. Why it is called SSD? Simple because it has no moving parts like mechanical HDD and that makes it more reliable and less power hungry. SSD are basically a NAND based flash drive.This means no moving parts, and thus no spin-up speed, which results in shorter boot times. It also means faster read speeds from idle, and faster write speeds for larger files.SSD can be much smaller than mechanical HDD.MicroSD cards are a good demonstration of this, as is the seemingly endless increase in the capacity of USB keys.The nature of flash memory also means that it can survive through a larger temperate range, with some flash drives operating at up to 70 degrees Celsius. Though there are many advantages it is still emerging while mechanical HDD is mature technology but it will eventually replace them. As I write this Intel has released 320GB SSD this month and size will grow and price will drop. So stay tuned and keep your eyes open for SSD.
22 January 2009
.NET 3.5 's LINQ (Language Integrated Query) feature : A case study
1. Introduction
LINQ is the abbreviation of Language integrated query, the new component added in the Microsoft’s .Net version 3.5. LINQ is available in C#3.0 and Visual Basic 9.0. It provides the unified way to query not only relational databases but also XML documents and in memory objects. It is an initiative towards providing facility to the programmers for getting away from writing database specific or XML document specific query to retrieve particular data.
In this report we will look at what is the LINQ in general, how it is different from using traditional ADO.Net concepts like DataSet, DataAdapter etc. and evaluate it for the use in the organization, and its advantages and disadvantages compared to the traditional approach of using ADO.Net and brief look at what are the pros and cons of traditional ADO.Net approach. Final section of the report will conclude the findings.
2. Overview of LINQ
Most of the enterprise level application requires some short of database access and .Net applications that access database are generally use ADO.Net to do so. If the programmer needs to access the XML document to perform some query on it the way to do that is different than to access the data from the relational database. LINQ is developed to unify this process of operating on different kind of data sources. So this will reduce the effort required by the programmer to deal with different kind of database. LINQ also support the way to query collection of objects in memory, similar to the way programmers query the database table. This new feature of LINQ to Object will provides easier way to the programmers to deal with some complex operations on collection of objects. For example, find the element whose length is 5 characters. In traditional approach the programmer may loop through the collection of objects and check that the element’s length is 5 or not. LINQ provides facility to query the collection of elements by using syntax like:
string[] names = {"John", "Peter", "Joe", "Patrick", "Donald"};
IEnumerable namesWithFiveCharacters =from name in names where name.Lenght==5 select name;
LINQ to Object can be applied to any type as long as it inherits from the IEnumerable. Previous example of using LINQ to query the array of strings is called LINQ to Object. LINQ can be classified into other categories link DLINQ (LINQ to SQL) that deals with querying to the relational database and XLINQ (LINQ to XML) that deals with querying XML document. LINQ supports different kind of query operators like aggregating the data, performing grouping or joining tables etc.
The previous example is written using simple query mechanism. There is another flavour available to write the same query using methods and lambda expressions. This way of writing query is called method-based query.
Following example shows the method-based query:
IEnumerable query = names
.Where(s => s.Length == 5)
.OrderBy(s => s)
.Select(s => s.ToUpper());
Here every clause is used as a method and the arguments that are passed to the methods are called lambda expressions.
2.1 LINQ to SQL (DLINQ):
LINQ to SQL let the programmer write the query in their preferred language and leave to convert it into the database specific query to the .Net compiler. Another advantage that LINQ provides over traditional way of using ADO.Net is that if there is an error in the query it will be reported during the compilation of the code and not during the execution. This will definitely save time in writing and debugging code. LINQ can be used to perform any kind of query to select the data or to manipulate the data in the database. Following example shows how the LINQ to SQL simplifies the process of writing query.
HookedOnLINQ db = new HookedOnLINQ("Data Source=(local);Initial Catalog=HookedOnLINQ");
var q = from c in db.Contact
where c.DateOfBirth.AddYears(35) > DateTime.Now
orderby c.DateOfBirth descending
select c;
Once the value is retrieved in variable q you can iterate thorough it to get the results that you wants.
2.2 LINQ to XML (XLINQ):
Many times XML is used to store data for the portability reasons. This method become increasingly popular and that leads to many techniques to deal with XML documents like XQuery, XPath, XSLT, XSL etc. XLINQ is yet another addition to those list but it is more flexible and powerful then those other techniques. XLINQ not only helps to query the XML documents but also supports generation of the XML document. This will eliminates the need for using DOM or XML APIs to work with it. Similar to DLINQ, XLINQ provides easier way to deal with generation and manipulation of XML documents that are used to store data. In the recent version of .Net, XQuery is used to query the XML document while SQL is used to retrieve data from the databases. LINQ unifies this process of retrieving data from different data sources like XML document or relational databases. XLINQ is more flexible to work with then XML DOM because it does not require whole document in the memory to work with it. XLINQ provides all functionalities of DOM, XQuery, XPath, XSLT, and MSXML.
Following code shows how easy to generate XML document using XLINQ.
XDocument bookStoreXml =new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("Bookstore XML Example"),
new XElement("bookstore",
new XElement("genre",
new XAttribute("name",
"Fiction"),));
Following code shows how to query the XML file to retrieve data from it using XLINQ:
XElement allData = XElement.Load("Authors.xml");
if (allData != null)
{
IEnumerable authors = allData.Descendants("Author");
foreach(XElement author in authors)
Console.WriteLine((string)author);
}
These codes indicate the new method of using LINQ to generate and query XML document. We no longer needs any old XML APIs .
3. Comparing Usage of LINQ to Current ADO.Net Approach
Vary first observation from above examples is that the way of writing query is different for traditional ADO.Net and LINQ. For example, In ADO.Net the query to retrieve data from the database starts with select while in LINQ it starts with from clause. So the programmers who are willing to use LINQ will needs to keep this basic thing in mind and it will initially takes a while to get away from the old habit of writing query in ADO.Net manner. Another important change in the query compared to the traditional approach is that you do not needs to specify how the query should execute and in which order. The LINQ takes care of forming the proper query by supplied values. So the programmer just needs to specify what is expected from the query and provide appropriate parameters to the clauses or to the methods in method-based query. LINQ provides many extension methods to deal with complex operations like joining the tables or grouping the data by particular condition. Writing such queries in traditional ADO.Net approach is fairly complex and takes longer to understand and debug as well. LINQ makes writing such queries simple by use of extended methods. This will make code more readable as well. All the extension methods that are used by LINQ are defined in System. LINQ Enumerable class. Example of the extensions methods are Any, All, Max, Min, Join, GroupBy, GroupJoin, OrderBy, ThenBy, Select, SelectMany ,Where etc. Most of the time the programmer needs to type cast the different data type from the database to the programming language format and vice versa. This job is tedious as well, for example, type casting VARCHAR into the integer data type to use that data in the code to get the desired output. This short of conversion requires handling the exceptions programmatically and that leads to more code. Another issue with using this traditional approach of ADO.Net is that the database code get scattered in many places. This is not a problem for the small projects but in the large project this will leads to more code management issues later. All those issues can be resolved by using LINQ that provides one layer of abstraction then directly using ADO.Net call level interfaces (CLI). ADO.Net provides data in DataSet or DataReader and the programmer has to iterate through it to get the data back into the objects while LINQ directly offers the data as objects.
4. Advantages of LINQ
The aim of LINQ is to solve the problem that we are currently facing to use different techniques for manipulating and selecting data from databases versus XML or versus object collections. The purpose of LINQ is to make our life easier by giving us a consistent and efficient syntax from our development environment. Below are some advantages of using LINQ:
• The main advantage of using LINQ is that it works with any data source. Users can put very less effort to change between data sources if necessary. LINQ enable languages have a compile time checking of query, good intelligence, and debugging support.
• One of the C#.NET features that LINQ can support is the “Anonymous Types”. This allows programmer to create and use the type structures as is without having to formally declare their object model. This is really useful when working with custom data type using LINQ queries. For example, if you working against a database or strongly-typed collection that has many properties, but you only need a few of them, the rest of the types are useless to you. Without using LINQ, you need to create and work against the full type. However, LINQ is useful to return those properties that you need.
• LINQ can be used with objects, collections, XML, database etc. Searching a collection or a node in XML is fairly easy to implement using XLINQ. LINQ uses queries similar to SQL, which is rather easy compared to querying an XML through old XML APIs.
• LINQ queries can allow users to create, read, and update a database and it can support the relationships that are defined in the database. For example, It allows the use of same syntax as general SQL syntax that is used to join tables based on the keys.
• Another advantage is availability of LINQ to DataSet. LINQ can make it fast and easy to query over data cached into a DataSet objects. This is because LINQ is simplifies the querying mechanism by allowing users to writes their own queries, instead using the separate query languages.
5. Disadvantages of LINQ
Although LINQ come with such advantage to the developers, just like other techniques there are some disadvantages for using LINQ as well. some issues or disadvantages of using LINQ are as follow:
• Stored procedures can be used with LINQ but it is not recommended. LINQ generates T-SQL query dynamically to operate on tables or views. It leads to the always debated question of whether the use of stored procedure is good or not? Currently there is no wizard available that can generate the stored procedure supported by LINQ.
• LINQ adds a layer that encapsulates the use of call level interfaces directly on the database or XML document. During the execution of the code the query is generated dynamically by the .Net. This will leads to slight performance degradation as the time is required to convert method calls in LINQ to appropriate query.
• LINQ to SQL (DLINQ) select statement is generally “select * from…” kind that will leads to too much or too little data in a single query. Too little data in a query is bad because then there is a need for many trips to the database to retrieve data. Furthermore, There are some concerned when using LINQ to SQL, such as security, entities with no primary key, entities with composite primary key, many-to-many relationships and globalization, etc.
• Evan though you find a performance issue with the LINQ it is not possible to tune it as it requires too much effort to change the underlying APIs that work for LINQ.
• LINQ can generate entity classes and even can extend them with partial classes and inheritance. However, the control over the classes is still limited. Developers don’t have much control as other language, such as NHibernate.
• LINQ generates query dynamically and that leads to another issue of finding problem if something goes wrong. In the traditional approach of ADO.Net the programmer can look at the query that is written in the programme and can able to find some fault. In LINQ this process of finding problems in the query is hard if something goes wrong. This situation becomes worst in the case of large application and if the application stopes working in a way it suppose to after it is deployed. There may not be any syntax error but it can be a logical error or may be the side effect of some change in the database schema itself.
• In large organization generally DBA provides the access to the database through stored procedures. While in LINQ the query is generated dynamically and that will leads to the issue of giving access of database to the developers or just use stored procedure facility of LINQ. Particularly when dealing with some critical databases there is more concern on what kind of access is to be provided to the developers. The queries generated by developers also raise the concern of tuning it as the DBA cannot look at each and every piece of code to fine tune it. It will be easier to DBA to look at stored procedures and make the changes in it.
6. Advantages of ADO.Net
In this section we will look briefly at the advantages of using current approach of using ADO.Net for data access. It was the main data access component in the .Net framework prior to introduction of LINQ. According to the MSDN Library (2005) some of the benefits offered by ADO.Net are:
• ADO.Net provides interoperability between databases because it can operate on XML documents. If the destination database is capable of reading XML document then the data can be passed between different databases. ADO.Net provides facility to work with any database and XML documents.
• ADO.Net provides easier maintainability of application by passing data between tiers as DataSet rather than any other object type. So if in future there is a need to add a tier to the deployed application it can be done easily.
• Programming ADO.Net to access and manipulate data is easy compared to prior versions of ADO like OLEDB.
• ADO.Net DataSet provides better performance compared to older version of ADO RecordSet as well as LINQ. LINQ takes time to generate query dynamically while in ADO.Net query is passed as a string object. In ADO use of COM marshalling to transfer data as RecordSet between tiers takes time to marshal and unmarshal it to convert into understandable data type of COM.
• ADO.Net is capable of working with data in a disconnected way.
7. Disadvantages of ADO.Net
Some of the disadvantages of using ADO.Net for accessing database or XML document are described briefly as below:
• There is no interoperability between COM and ADO.Net. ADO.Net only runs under CLR referred as managed only access. So if there is a need to use facilities like DataSet or XML internal data storage the programmer must need CLR.
• If the programmer needs to access data that requires a driver that cannot be used through either an OLEDB provider or the SQL Server Data Provider then there is no other alternative. Although, there is an OLEDB provider for ODBC is available for download from Microsoft but if there is no bridge available then there is no other way to use that database.
• ADO.Net supports both database and XML documents but it does not unify the process of dealing with them. LINQ is better in that aspect. ADO.Net uses different APIs and methods to deal with database and XML documents.
8. Conclusion
LINQ is certainly a technology to look after to deal with different kind of data sources. LINQ unifies the process of dealing with different kind of databases and XML documents to retrieve and manipulate the data. LINQ query is more readable and it is easier to write complex queries compared to the traditional approach of using ADO.Net. There is an initial learning curve for the programmers who want to adopt the LINQ as their preferred way of interacting with database. As every technique has its pros and cons and LINQ is no exception to it. There is already concern about performance issue and maintenance of the code. Still, LINQ is a useful technique and it will change the way programmers write their code to deal with databases and XML documents in the future.
LINQ is the abbreviation of Language integrated query, the new component added in the Microsoft’s .Net version 3.5. LINQ is available in C#3.0 and Visual Basic 9.0. It provides the unified way to query not only relational databases but also XML documents and in memory objects. It is an initiative towards providing facility to the programmers for getting away from writing database specific or XML document specific query to retrieve particular data.
In this report we will look at what is the LINQ in general, how it is different from using traditional ADO.Net concepts like DataSet, DataAdapter etc. and evaluate it for the use in the organization, and its advantages and disadvantages compared to the traditional approach of using ADO.Net and brief look at what are the pros and cons of traditional ADO.Net approach. Final section of the report will conclude the findings.
2. Overview of LINQ
Most of the enterprise level application requires some short of database access and .Net applications that access database are generally use ADO.Net to do so. If the programmer needs to access the XML document to perform some query on it the way to do that is different than to access the data from the relational database. LINQ is developed to unify this process of operating on different kind of data sources. So this will reduce the effort required by the programmer to deal with different kind of database. LINQ also support the way to query collection of objects in memory, similar to the way programmers query the database table. This new feature of LINQ to Object will provides easier way to the programmers to deal with some complex operations on collection of objects. For example, find the element whose length is 5 characters. In traditional approach the programmer may loop through the collection of objects and check that the element’s length is 5 or not. LINQ provides facility to query the collection of elements by using syntax like:
string[] names = {"John", "Peter", "Joe", "Patrick", "Donald"};
IEnumerable
LINQ to Object can be applied to any type as long as it inherits from the IEnumerable. Previous example of using LINQ to query the array of strings is called LINQ to Object. LINQ can be classified into other categories link DLINQ (LINQ to SQL) that deals with querying to the relational database and XLINQ (LINQ to XML) that deals with querying XML document. LINQ supports different kind of query operators like aggregating the data, performing grouping or joining tables etc.
The previous example is written using simple query mechanism. There is another flavour available to write the same query using methods and lambda expressions. This way of writing query is called method-based query.
Following example shows the method-based query:
IEnumerable
.Where(s => s.Length == 5)
.OrderBy(s => s)
.Select(s => s.ToUpper());
Here every clause is used as a method and the arguments that are passed to the methods are called lambda expressions.
2.1 LINQ to SQL (DLINQ):
LINQ to SQL let the programmer write the query in their preferred language and leave to convert it into the database specific query to the .Net compiler. Another advantage that LINQ provides over traditional way of using ADO.Net is that if there is an error in the query it will be reported during the compilation of the code and not during the execution. This will definitely save time in writing and debugging code. LINQ can be used to perform any kind of query to select the data or to manipulate the data in the database. Following example shows how the LINQ to SQL simplifies the process of writing query.
HookedOnLINQ db = new HookedOnLINQ("Data Source=(local);Initial Catalog=HookedOnLINQ");
var q = from c in db.Contact
where c.DateOfBirth.AddYears(35) > DateTime.Now
orderby c.DateOfBirth descending
select c;
Once the value is retrieved in variable q you can iterate thorough it to get the results that you wants.
2.2 LINQ to XML (XLINQ):
Many times XML is used to store data for the portability reasons. This method become increasingly popular and that leads to many techniques to deal with XML documents like XQuery, XPath, XSLT, XSL etc. XLINQ is yet another addition to those list but it is more flexible and powerful then those other techniques. XLINQ not only helps to query the XML documents but also supports generation of the XML document. This will eliminates the need for using DOM or XML APIs to work with it. Similar to DLINQ, XLINQ provides easier way to deal with generation and manipulation of XML documents that are used to store data. In the recent version of .Net, XQuery is used to query the XML document while SQL is used to retrieve data from the databases. LINQ unifies this process of retrieving data from different data sources like XML document or relational databases. XLINQ is more flexible to work with then XML DOM because it does not require whole document in the memory to work with it. XLINQ provides all functionalities of DOM, XQuery, XPath, XSLT, and MSXML.
Following code shows how easy to generate XML document using XLINQ.
XDocument bookStoreXml =new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("Bookstore XML Example"),
new XElement("bookstore",
new XElement("genre",
new XAttribute("name",
"Fiction"),));
Following code shows how to query the XML file to retrieve data from it using XLINQ:
XElement allData = XElement.Load("Authors.xml");
if (allData != null)
{
IEnumerable
foreach(XElement author in authors)
Console.WriteLine((string)author);
}
These codes indicate the new method of using LINQ to generate and query XML document. We no longer needs any old XML APIs .
3. Comparing Usage of LINQ to Current ADO.Net Approach
Vary first observation from above examples is that the way of writing query is different for traditional ADO.Net and LINQ. For example, In ADO.Net the query to retrieve data from the database starts with select while in LINQ it starts with from clause. So the programmers who are willing to use LINQ will needs to keep this basic thing in mind and it will initially takes a while to get away from the old habit of writing query in ADO.Net manner. Another important change in the query compared to the traditional approach is that you do not needs to specify how the query should execute and in which order. The LINQ takes care of forming the proper query by supplied values. So the programmer just needs to specify what is expected from the query and provide appropriate parameters to the clauses or to the methods in method-based query. LINQ provides many extension methods to deal with complex operations like joining the tables or grouping the data by particular condition. Writing such queries in traditional ADO.Net approach is fairly complex and takes longer to understand and debug as well. LINQ makes writing such queries simple by use of extended methods. This will make code more readable as well. All the extension methods that are used by LINQ are defined in System. LINQ Enumerable class. Example of the extensions methods are Any, All, Max, Min, Join, GroupBy, GroupJoin, OrderBy, ThenBy, Select, SelectMany ,Where etc. Most of the time the programmer needs to type cast the different data type from the database to the programming language format and vice versa. This job is tedious as well, for example, type casting VARCHAR into the integer data type to use that data in the code to get the desired output. This short of conversion requires handling the exceptions programmatically and that leads to more code. Another issue with using this traditional approach of ADO.Net is that the database code get scattered in many places. This is not a problem for the small projects but in the large project this will leads to more code management issues later. All those issues can be resolved by using LINQ that provides one layer of abstraction then directly using ADO.Net call level interfaces (CLI). ADO.Net provides data in DataSet or DataReader and the programmer has to iterate through it to get the data back into the objects while LINQ directly offers the data as objects.
4. Advantages of LINQ
The aim of LINQ is to solve the problem that we are currently facing to use different techniques for manipulating and selecting data from databases versus XML or versus object collections. The purpose of LINQ is to make our life easier by giving us a consistent and efficient syntax from our development environment. Below are some advantages of using LINQ:
• The main advantage of using LINQ is that it works with any data source. Users can put very less effort to change between data sources if necessary. LINQ enable languages have a compile time checking of query, good intelligence, and debugging support.
• One of the C#.NET features that LINQ can support is the “Anonymous Types”. This allows programmer to create and use the type structures as is without having to formally declare their object model. This is really useful when working with custom data type using LINQ queries. For example, if you working against a database or strongly-typed collection that has many properties, but you only need a few of them, the rest of the types are useless to you. Without using LINQ, you need to create and work against the full type. However, LINQ is useful to return those properties that you need.
• LINQ can be used with objects, collections, XML, database etc. Searching a collection or a node in XML is fairly easy to implement using XLINQ. LINQ uses queries similar to SQL, which is rather easy compared to querying an XML through old XML APIs.
• LINQ queries can allow users to create, read, and update a database and it can support the relationships that are defined in the database. For example, It allows the use of same syntax as general SQL syntax that is used to join tables based on the keys.
• Another advantage is availability of LINQ to DataSet. LINQ can make it fast and easy to query over data cached into a DataSet objects. This is because LINQ is simplifies the querying mechanism by allowing users to writes their own queries, instead using the separate query languages.
5. Disadvantages of LINQ
Although LINQ come with such advantage to the developers, just like other techniques there are some disadvantages for using LINQ as well. some issues or disadvantages of using LINQ are as follow:
• Stored procedures can be used with LINQ but it is not recommended. LINQ generates T-SQL query dynamically to operate on tables or views. It leads to the always debated question of whether the use of stored procedure is good or not? Currently there is no wizard available that can generate the stored procedure supported by LINQ.
• LINQ adds a layer that encapsulates the use of call level interfaces directly on the database or XML document. During the execution of the code the query is generated dynamically by the .Net. This will leads to slight performance degradation as the time is required to convert method calls in LINQ to appropriate query.
• LINQ to SQL (DLINQ) select statement is generally “select * from…” kind that will leads to too much or too little data in a single query. Too little data in a query is bad because then there is a need for many trips to the database to retrieve data. Furthermore, There are some concerned when using LINQ to SQL, such as security, entities with no primary key, entities with composite primary key, many-to-many relationships and globalization, etc.
• Evan though you find a performance issue with the LINQ it is not possible to tune it as it requires too much effort to change the underlying APIs that work for LINQ.
• LINQ can generate entity classes and even can extend them with partial classes and inheritance. However, the control over the classes is still limited. Developers don’t have much control as other language, such as NHibernate.
• LINQ generates query dynamically and that leads to another issue of finding problem if something goes wrong. In the traditional approach of ADO.Net the programmer can look at the query that is written in the programme and can able to find some fault. In LINQ this process of finding problems in the query is hard if something goes wrong. This situation becomes worst in the case of large application and if the application stopes working in a way it suppose to after it is deployed. There may not be any syntax error but it can be a logical error or may be the side effect of some change in the database schema itself.
• In large organization generally DBA provides the access to the database through stored procedures. While in LINQ the query is generated dynamically and that will leads to the issue of giving access of database to the developers or just use stored procedure facility of LINQ. Particularly when dealing with some critical databases there is more concern on what kind of access is to be provided to the developers. The queries generated by developers also raise the concern of tuning it as the DBA cannot look at each and every piece of code to fine tune it. It will be easier to DBA to look at stored procedures and make the changes in it.
6. Advantages of ADO.Net
In this section we will look briefly at the advantages of using current approach of using ADO.Net for data access. It was the main data access component in the .Net framework prior to introduction of LINQ. According to the MSDN Library (2005) some of the benefits offered by ADO.Net are:
• ADO.Net provides interoperability between databases because it can operate on XML documents. If the destination database is capable of reading XML document then the data can be passed between different databases. ADO.Net provides facility to work with any database and XML documents.
• ADO.Net provides easier maintainability of application by passing data between tiers as DataSet rather than any other object type. So if in future there is a need to add a tier to the deployed application it can be done easily.
• Programming ADO.Net to access and manipulate data is easy compared to prior versions of ADO like OLEDB.
• ADO.Net DataSet provides better performance compared to older version of ADO RecordSet as well as LINQ. LINQ takes time to generate query dynamically while in ADO.Net query is passed as a string object. In ADO use of COM marshalling to transfer data as RecordSet between tiers takes time to marshal and unmarshal it to convert into understandable data type of COM.
• ADO.Net is capable of working with data in a disconnected way.
7. Disadvantages of ADO.Net
Some of the disadvantages of using ADO.Net for accessing database or XML document are described briefly as below:
• There is no interoperability between COM and ADO.Net. ADO.Net only runs under CLR referred as managed only access. So if there is a need to use facilities like DataSet or XML internal data storage the programmer must need CLR.
• If the programmer needs to access data that requires a driver that cannot be used through either an OLEDB provider or the SQL Server Data Provider then there is no other alternative. Although, there is an OLEDB provider for ODBC is available for download from Microsoft but if there is no bridge available then there is no other way to use that database.
• ADO.Net supports both database and XML documents but it does not unify the process of dealing with them. LINQ is better in that aspect. ADO.Net uses different APIs and methods to deal with database and XML documents.
8. Conclusion
LINQ is certainly a technology to look after to deal with different kind of data sources. LINQ unifies the process of dealing with different kind of databases and XML documents to retrieve and manipulate the data. LINQ query is more readable and it is easier to write complex queries compared to the traditional approach of using ADO.Net. There is an initial learning curve for the programmers who want to adopt the LINQ as their preferred way of interacting with database. As every technique has its pros and cons and LINQ is no exception to it. There is already concern about performance issue and maintenance of the code. Still, LINQ is a useful technique and it will change the way programmers write their code to deal with databases and XML documents in the future.
21 January 2009
Intel Core i7 Processor
Technology is changing rapidly and particularly in the arena of processors there are changes beyond imagination. I still remember the days when we were programming on Intel's 8085 processor boards !! It really sounds ages old now with emergence of core architecture and now moving towards tile architecture. I should mention that a small firm called Tilera came up with Tile 64 architecture. As simple as it sounds 64 processors in a single chip. Sorry for going bit off track here we are talking about Intel's core i7 the much anticipated and talked about processor.
It has 4 cores in a single chip sharing a queue to work alongside one another. Core i7's design is based on Core 2 processors but it is changed a lot the way interfaces are provided for memory and I/O. There is a three layers of catch shared between cores.One mechanism Intel uses to make its caches more effective is prefetching, in which the hardware examines memory access patterns and attempts to fill the caches speculatively with data that's likely to be requested soon.There is an integrated memory controller in the processor itself to access main memory very fast.
With the memory controller onboard and the front-side bus gone, the Core i7 communicates with the rest of the system via the QuickPath interconnect, or QPI. QuickPath is Intel's answer to HyperTransport, a high-speed, narrow, packet-based, point-to-point interconnect between the processor and the I/O chip.
You can read more technical specs about it on:
Wikipedia: Core i7
20 January 2009
Application Architecture Guide 2.0
A really good book for Developers and architects to read about Design Patterns and practices. It is particularly targeted at .NET framework and covers all kind of applications from web development to RIA to N-tier enterprise grade architecture. Above all its free to download from Here. It gives a fairly good idea about design principles.
Subscribe to:
Posts (Atom)