Tuesday, September 27, 2011

SQL to LINQ converter

Try this tool : 
http://www.linqpad.net/

Using LINQPad to test your LINQ to XML queries


Using LINQPad to test your LINQ to XML queries

Sunday, 6 February 2011 12:55 by mha
If you’re a LINQPad user you’re probably used to query your DBML (LINQ to SQL), but did you know that you can also use it for LINQ to Objects, LINQ to XML etc.
A simple example of how to do a query against a XML file (make sure language is set to C# Statements):
var xml = XElement.Load (@"c:\\inetpub\\GWportal\\src\\wwwBackend\\App_Data\\axCache\\ 
   GWDK\productprice-mha.xml");
var query = 
  from e in xml.Descendants("unittransaction").Descendants() 
    where (e.Attribute("name").Value == "ItemRelation" && e.Value.Equals("10020")) 
  select e.Parent; 
  
query.Dump();
Which gives this result:

Get Query String Using Javascript

To get query string using Javascript:

temp = window.location.search.substring(1);

document.write(
temp);

-We create a variable temp

-Built-in Javascript properties: window.location is the entire url. search.substring(1) is the part after the question mark.
-We write the value of temp to the browser.

Below is a function that will break the query string into pieces for you:


Copy and Paste Javascript Code:

<script type="text/javascript">
<!--

function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}

var koko = querySt("koko");

document.write(koko);
document.write("<br>");
document.write(hu);

-->
</script>