tags:

views:

37

answers:

0

Hello Everybody,

I want get all contry and cities from database to SilverLight Application, SO I Create Cutom Generic Lists. This is My Country Class .

[DataContract]
public class Country<T>:List<T> where T:City
{
    [DataMember]
    public int Country_Id { get; set; }
    [DataMember]
    public string Country_Name { get; set; }
}

This is City Class

[DataContract]
[KnownType(typeof(Country<City>))]    
public class City
{
    [DataMember]
    public int City_Code { get; set; }
    [DataMember]
    public string City_Name { get; set; }

}

This Service Interface

[ServiceContract(Namespace = Information.Namespace.Contact)]
public interface ILocation
{  
[OperationContract]
[FaultContract(typeof(FaultDetail))]       
List<Country<City>> GetLocations();
}

This is My Service Implementation

public class LocationService:ILocation
{
 public List<Country<City>> GetLocations()
        {
            List<Country<City>> LocationDet = new List<Country<City>>();
            Country<City> LocationCon = new Country<City>() { Country_Id = 1, Country_Name = "India" };
            LocationCon.Add(new City() { City_Code = 1, City_Name = "Chennai" });
            LocationDet.Add(LocationCon);
            return LocationDet;
        }
 }

When I Call From SilverLight Application It Through an CoummunicationException.

Please give me some suggestions

Thanks.