Skip to main content

Posts

Showing posts from December, 2010

How to:Create wcf application without using config file

In this post i am going to show you how to create wcf application without using config file. Let's start the tutorial.
Open visual studio and create a new console application Right click on the project and add reference to following assemblyusing System.ServiceModel;
Open Program.cs file and paste following code
[ServiceContract]     interface IService     {         [OperationContract]         string HelloWorld(string strMessage);     }     publicclass ServiceImp : IService     {         [OperationBehavior]         publicstring HelloWorld(string strMessage)         {             return ("Hello " + strMessage + "!");         }     }
Now Add following code inside main method

staticvoid Main(string[] args)         {             //Create a URI to serve as the base address             Uri httpUrl = new Uri("http://localhost:8090/MyService");             //Create ServiceHost             ServiceHost host = new ServiceHost(typeof(ServiceImp), httpUrl);����������…

Linq to Sql: Left outer join

In this post i am going to show how to generate left outer join using linq to sql. For this post i am going to use Categories and Product table of northwind. First way to generate left outer join var query=from p in Products join c in Categories on p.CategoryID equals c.CategoryID into pc where p.CategoryID==1 from j in pc.DefaultIfEmpty() select new { CategoryName=j.CategoryName, ProductName=p.ProductName }; ouput generated code SELECT [t1].[CategoryName] AS [CategoryName], [t0].[ProductName] FROM [Products] AS [t0] LEFTOUTERJOIN [Categories] AS [t1] ON [t0].[CategoryID] = ([t1].[CategoryID]) WHERE [t0].[CategoryID] = @p0 second way without using into operator var query=from p in Products from c in Categories.Where(x=>x.CategoryID==p.CategoryID).DefaultIfEmpty() select new { CategoryName=c.CategoryName, ProductName=p.ProductName …

Linq to Sql:Inner join

In this post i am going to show you how to generate inner join using linq to sql.
For this post i am going to use Categories and Product table of northwind.



Let's imagine that you want to fetch CategoryName and ProductName from above table using linq.



var query=from p in Products           join c in Categories           on p.CategoryID equals c.CategoryID           select new           {           CategoryName=c.CategoryName,           ProductName=p.ProductName           };

Jquery and CheckboxList

In this post i am going to show you how use jquery in asp.net to select the checkbox of Checkbox List <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadioButtonListJquery.aspx.cs" Inherits="RadioButtonListJquery" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><scriptsrc="Scripts/jquery-1.3.2.js"type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("#selectAll").click(function () { $("input[type='checkbox'").not("#selectAll").each(function () { $(this).attr("checked", "true"); }); …

How DataContract serialize CLR object into XML

In this post,I am going to show you how DataContract export DataContract into xsd ,and then how an object is converted into xml.





using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization; using System.Xml.Schema; using System.Xml; namespace DataContract_Demo {     [DataContract(Namespace = "http://aspdotnetcodebook.blogspot.com", Name = "Person")]     publicclass Person     {         [DataMember(Name = "FirstName")]         publicstring FirstName { get; set; }         [DataMember(Name = "LastName")]         publicstring LastName { get; set; }     }     class Program     {         staticvoid Main(string[] args)         {             GenerateXsd();             GenerateXML();         }         privatestaticvoid GenerateXsd()         {             XsdDataContractExporter exporter = new XsdDataContractExporter();             exporter.Export(typeof(Person));             foreach (XmlS…