WCF/WF - error : Not all code path return a value

Asked By shoaib mansoori on 23-Feb-11 09:51 PM

My IService coding
[ServiceContract]

public interface IServiceCustomer

{

[OperationContract]

List<clsCustomer> getCustomer();

}

[DataContract]

public class clsCustomer

{

private string CustomerCode;

private string CustomerName;

[DataMember]

public string _CustomerCode

{

get { return CustomerCode; }

set { CustomerCode = value; }

}

[DataMember]

public string _CustomerName

{

get { return CustomerName; }

set { CustomerName = value; }

}

}

My Service1 coding

public class ServiceCustomer : IServiceCustomer

{

public List<clsCustomer> getCustomer()

{

List<clsCustomer> objcus = new List<clsCustomer>();

SqlConnection objcon = new SqlConnection();

objcon.Open();

 

}


}

on getcustomer i am facing error

Santhosh N replied to shoaib mansoori on 23-Feb-11 10:34 PM
When you write any method with return type you must return that type from each condition.. otherwise it leads to this error

public List<clsCustomer> getCustomer()

{

List<clsCustomer> objcus = new List<clsCustomer>();

SqlConnection objcon = new SqlConnection();

objcon.Open();

//here you need to return List<ClsCustomer> object from here... 

}


}