tag:blogger.com,1999:blog-33275241723822348422024-02-01T20:48:56.560-08:00Nikunj's blognikunj's bloghttp://www.blogger.com/profile/17357060186523106664noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-3327524172382234842.post-58612355578292186872010-05-18T21:42:00.000-07:002010-05-18T21:49:51.890-07:00What is Linq,DLinq & XLinq?<div style="font-family: "Courier New",Courier,monospace;"><span class="articleText">The Linq project offers querying features integrated right into programming languages. This will allow executing strongly-typed queries on sources such as databases, XML documents or even object graphs in memory. This technology relies on innovations on programming languages like C# 3 or VB.NET 9, and it will be ported to other .NET languages like Delphi.</span></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><span class="articleText"><b>DLinq</b> is an extension to Linq that allows querying a database (only SQL Server for the moment) and do object-relational mapping.<br />
<b>XLinq</b> is an extension to Linq that allows querying XML documents, as well as creating or transforming XML.</span><span class="articleText"> </span></div><div style="font-family: "Courier New",Courier,monospace;"><span class="articleText"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span class="articleText">Like for DLinq,</span></div><div style="font-family: "Courier New",Courier,monospace;">Here is what is performed in each case:</div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;">We just execute a simple query: <span style="color: blue; font-size: x-small;"> <span style="font-size: small;">return<br />
from</span></span><span style="font-size: small;"> cst </span> <span style="color: blue; font-size: small;">in</span><span style="font-size: small;"> _db.Customers<br />
</span><span style="color: blue; font-size: small;">where</span><span style="font-size: small;"> </span><span style="font-size: small;">cst</span><span style="font-size: small;">.Country == country<br />
</span><span style="color: blue; font-size: small;">select</span><span style="font-size: small;"> cst</span><span style="font-size: small;">;</span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">we can map through the all records using IEnumerable or IQueryable object.</span></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">Like for XLinq,</span></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivMSIOkXx9bPXQAm5oix7d2g4Pex5jWzcdyON3v1l61rk3pZENB6YcmCpiF8NgsetcQyHRYr7rG-8qXTr82YQ3K1QLXRg6va1fQ35aUj7nBBlCzfak9A40rimfgP0ARYa6-Y1Kra4y1rU/s1600/Xml.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="107" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivMSIOkXx9bPXQAm5oix7d2g4Pex5jWzcdyON3v1l61rk3pZENB6YcmCpiF8NgsetcQyHRYr7rG-8qXTr82YQ3K1QLXRg6va1fQ35aUj7nBBlCzfak9A40rimfgP0ARYa6-Y1Kra4y1rU/s640/Xml.jpg" width="640" /></a></div><span style="font-size: small;"><customer email="test@test.com" id="FAMIA" website="http://arquibaldo.br"><webcustomers><customer email="test@test.com" id="FAMIA" website="http://arquibaldo.br"><webcustomers><customer email="test@test.com" id="FAMIA" website="http://arquibaldo.br"> // Load XML<br />
var webCustomers = XElement.Parse(xmlData);<br />
<br />
// Create view<br />
var result = from customer in customers, webCustomer in webCustomers.Elements()<br />
where customer.CustomerID == webCustomer.Attribute("ID").Value<br />
select new {<br />
ID = customer.CustomerID,<br />
Name = customer.CompanyName,<br />
EMail = webCustomer.Attribute("EMail").Value,<br />
WebSite = webCustomer.Attribute("WebSite").Value};<br />
<br />
// Display<br />
ObjectDumper.Write(result); </customer></webcustomers></customer></webcustomers></customer></span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> </span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;"> </span></div><div style="font-family: "Courier New",Courier,monospace;"><span style="font-size: x-small;"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span class="articleText"> regards,</span></div><div style="font-family: "Courier New",Courier,monospace;"><br />
</div><div style="font-family: "Courier New",Courier,monospace;"><span class="articleText"><br />
</span></div><div style="font-family: "Courier New",Courier,monospace;"><span class="articleText"><br />
</span></div>nikunj's bloghttp://www.blogger.com/profile/17357060186523106664noreply@blogger.com0tag:blogger.com,1999:blog-3327524172382234842.post-14649219587449558862010-05-18T05:26:00.000-07:002010-05-18T05:28:31.142-07:00New features of c# framework 4.0<h2 style="font-family: Arial,Helvetica,sans-serif;">New features of c# framework 4.0</h2><small></small> <br />
<div class="entry"><div class="snap_preview"><b>1]Dynamic:Now you can create dynamic objects and let their types be determined at run time.</b><br />
<br />
<b>2]Covariance and Contravariance:Variance on generic type parameters in interfaces and delegates is another important feature of this release. It doesn’t add much new functionality, but rather makes things work as you expected them to in the first place. The major advantage is hidden in this simple line, which didn’t compile until C# 4.0</b><br />
<br />
<b>3]Optional (or Default) Parameters:Now you can assign a default value to a parameter right within the method declaration. The user of the method can either pass a value or simply skip the argument. In the latter case, the default value is passed to the method.</b><br />
<br />
<b>4]Named Arguments:The order of parameters in a method declaration and the order of arguments you pass when calling the method don’t need to match anymore. You can provide arguments in any order you like by specifying parameter names in a method call. This might also improve the readability of your code.</b><br />
<br />
<b>5]Improved COM Interop:The introduction of the <b>dynamic</b> keyword, optional parameters and named arguments enables improvement of COM interop.</b><br />
<br />
Here are some links for further reading:<br />
<ul><li>Find all calls to and from your methods with the new <a href="http://msdn.microsoft.com/en-us/library/dd409859%28VS.100%29.aspx">Call Hierarchy</a> window.</li>
<li>Even if you have never heard of <a href="http://en.wikipedia.org/wiki/Test-driven_development">test-driven development (TDD)</a>, the <a href="http://msdn.microsoft.com/en-us/library/dd409796%28VS.100%29.aspx">Generate From Usage</a> feature may help you to quickly prototype your application by generating method and class stubs, allowing you to concentrate on your current task rather than worrying about declarations. For TDD adepts, this feature might be a real performance booster. Check out <a href="http://msdn.microsoft.com/en-us/library/dd998313%28VS.100%29.aspx">this walkthrough</a> for more details.</li>
<li>Don’t forget to take a look at <a href="http://msdn.microsoft.com/en-us/library/ms171868%28VS.100%29.aspx">What’s New in the .NET Framework 4</a> and also at <a href="http://msdn.microsoft.com/en-us/library/bb383815%28VS.100%29.aspx">What’s New in Visual C# 2010</a> (just to make sure I didn’t miss something).</li>
<li>And just in case, check out <a href="http://msdn.microsoft.com/en-us/library/ee855831%28VS.100%29.aspx">breaking changes for C#</a> and <a href="http://msdn.microsoft.com/en-us/library/ee941656%28VS.100%29.aspx">.NET Framework</a>.</li>
<li>Last, but not least, don’t forget to report any problems at <a href="http://connect.microsoft.com/VisualStudio">Microsoft Connect</a>.</li>
</ul>regards,<br />
<br />
"Please give me your valuable comments to improve my knowledge :) " <br />
<ul></ul></div></div>nikunj's bloghttp://www.blogger.com/profile/17357060186523106664noreply@blogger.com0tag:blogger.com,1999:blog-3327524172382234842.post-23114197265636408332010-05-18T03:26:00.000-07:002010-05-18T04:29:59.680-07:00What is basic difference between WCF and webservices?There are basically few difference which makes WCF more powerful that to the asp.net webservices,<br />
<br />
1] WCF services are <a href="http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Self-hosting-WCF-Services/">self hosting</a> means they dont need IIS setup<br />
2] WCF works on <a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx">DatacontractSerializer</a> while web services works on xml serializer<br />
3] WCF can handle private properties and fields<br />
4] The <a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx">DatacontractSerializer</a> can translate the HashTable into XML.<br />
<br />
regards,<br />
<br />
"Please give me your valuable comments to improve my knowledge :) "nikunj's bloghttp://www.blogger.com/profile/17357060186523106664noreply@blogger.com0tag:blogger.com,1999:blog-3327524172382234842.post-58941768321787311502010-05-17T22:57:00.000-07:002010-05-17T23:16:30.194-07:00Tell me which is faster VB or C#?Let me tell you brief story about the reason behind this question, one of my junior colleague has just joined my company, he always have new questions in mind, so he picked me to ask this question,<br /><br />"Tell me which is faster VB or C#?", i got dumb what to say but then i end up with c# without any reason because i am working on c# since last 3 years (without any reason),<br /><br />I search up many posts but some of them saying c# and some of them were saying VB,<br />I end up with zero for one day then with some more brainstorming i come with conclusion:<br /><br /><span style="font-weight: bold;">"Language can be any but Finally your code going to complied to IL which is same for VB and C#,</span><br /><span style="font-weight: bold;">So it depends on how you have coded and what amount of complexity have added"</span><br /><br />regards,<br /><br />"Please give me your valuable comments to improve my knowledge :) "nikunj's bloghttp://www.blogger.com/profile/17357060186523106664noreply@blogger.com1tag:blogger.com,1999:blog-3327524172382234842.post-26729233323440991812010-05-17T22:29:00.000-07:002010-05-17T23:06:06.450-07:00Dynamic type in c# 4.0Due to the languages like pyhton,ruby and growing technologies Microsoft introduced a new keyword name Dynamic in c# 4.0, we have var keyword for somehow same purpose.<br /><br />The dynamic capabilities of C# 4 are part of the Dynamic Language Runtime (DLR). The DLR is<br />a set of services that is added to the CLR to allow the addition of dynamic languages such as Ruby and Python. It also allows C# to take on some of the same dynamic capabilities that these dynamic languages have.<br /><br />There is a version of the DLR that is open source and resides on the CodePlex web site. This<br />same version is included with the .NET 4 Framework, with some additional support for language<br />implementers.<br /><br />In the .NET Framework, the DLR is found in the System.Dynamic namespace as well as a few<br />additional classes in the System.Runtime.CompilerServices namespace.<br />IronRuby and IronPython, which are open source versions of the Ruby and Python languages, use the DLR. Silverlight also uses the DLR. It ’ s possible to add scripting capabilities to your applications by hosting the DLR. The scripting runtime allows you to pass variables to and from the script.<br /><br />The Dynamic type will allow developer to assign any datatype instance without worrying about casting.<br /><br />like<br />dynamic dn = new Person();<br /><br /><br />Limitations:<br /><br />1] You cant query dynamic variable using Linq,<br />2] Even not supports Extension methods<br /><br />regards<br /><br />"Please give me your valuable comments to improve my knowledge :) "nikunj's bloghttp://www.blogger.com/profile/17357060186523106664noreply@blogger.com0