Это моя страница Iservice1.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data.SqlClient;
namespace WcfServiceTPO
{
[ServiceContract]
public interface IService1
{
[OperationContract]
dataconnect[] GetData(string level);
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class dataconnect
{
private string TpoChannelClassificationId;
private string TpoChannelClassificationCode;
private string TpoChannelClassificationShortName;
private string TpoChannelClassificationLongName;
private string TpoLoadDate;
private string TpoAccountID;
private string TpoAccountCode;
private string TpoAccountShortName;
private string TpoAccountLongName;
private string TpoAccountTDLinx;
private string TpoRegionId;
private string TpoRegionCode;
private string TpoRegionShortName;
private string TpoRegionLongName;
private string TpoRegionTDLinx;
private string TpoStoreid;
private string TpoStoreUnitCode;
private string TpostoreUnitShortName;
private string TpostoreUnitLongName;
private string TpoStoreTDLinx;
private string TpoCityid;
private string TpoStoreClusterid;
private string TpoNationalAccountFlag;
private string TpoStoreAddress;
[DataMember]
public string tpoChannelClassificationId
{
get
{
return TpoChannelClassificationId;
}
set
{
TpoChannelClassificationId = value;
}
}
[DataMember]
public string tpoChannelClassificationCode
{
get
{
return TpoChannelClassificationCode;
}
set
{
TpoChannelClassificationCode = value;
}
}
[DataMember]
public string tpoChannelClassificationShortName
{
get
{
return TpoChannelClassificationShortName;
}
set
{
TpoChannelClassificationShortName = value;
}
}
[DataMember]
public string tpoChannelClassificationLongName
{
get
{
return TpoChannelClassificationLongName;
}
set
{
TpoChannelClassificationLongName = value;
}
}
[DataMember]
public string tpoLoadDate
{
get
{
return TpoLoadDate;
}
set
{
TpoLoadDate = value;
}
}
[DataMember]
public string tpoAccountID
{
get
{
return TpoAccountID;
}
set
{
TpoAccountID = value;
}
}
[DataMember]
public string tpoAccountCode
{
get
{
return TpoAccountCode;
}
set
{
TpoAccountCode = value;
}
}
[DataMember]
public string tpoAccountShortName
{
get
{
return TpoAccountShortName;
}
set
{
TpoAccountShortName = value;
}
}
[DataMember]
public string tpoAccountLongName
{
get
{
return TpoAccountLongName;
}
set
{
TpoAccountLongName = value;
}
}
[DataMember]
public string tpoAccountTDLinx
{
get
{
return TpoAccountTDLinx;
}
set
{
TpoAccountTDLinx = value;
}
}
[DataMember]
public string tpoRegionId
{
get
{
return TpoRegionId;
}
set
{
TpoRegionId = value;
}
}
[DataMember]
public string tpoRegionCode
{
get
{
return TpoRegionCode;
}
set
{
TpoRegionCode = value;
}
}
[DataMember]
public string tpoRegionShortName
{
get
{
return TpoRegionShortName;
}
set
{
TpoRegionShortName = value;
}
}
[DataMember]
public string tpoRegionLongName
{
get
{
return TpoRegionLongName;
}
set
{
TpoRegionLongName = value;
}
}
[DataMember]
public string tpoRegionTDLinx
{
get
{
return TpoRegionTDLinx;
}
set
{
TpoRegionTDLinx = value;
}
}
[DataMember]
public string tpoStoreid
{
get
{
return TpoStoreid;
}
set
{
TpoStoreid = value;
}
}
[DataMember]
public string tpoStoreUnitCode
{
get
{
return TpoStoreUnitCode;
}
set
{
TpoStoreUnitCode = value;
}
}
[DataMember]
public string tpostoreUnitShortName
{
get
{
return TpostoreUnitShortName;
}
set
{
TpostoreUnitShortName = value;
}
}
[DataMember]
public string tpostoreUnitLongName
{
get
{
return TpostoreUnitLongName;
}
set
{
TpostoreUnitLongName = value;
}
}
[DataMember]
public string tpoStoreTDLinx
{
get
{
return TpoStoreTDLinx;
}
set
{
TpoStoreTDLinx = value;
}
}
[DataMember]
public string tpoCityid
{
get
{
return TpoCityid;
}
set
{
TpoCityid = value;
}
}
[DataMember]
public string tpoStoreClusterid
{
get
{
return TpoStoreClusterid;
}
set
{
TpoStoreClusterid = value;
}
}
[DataMember]
public string tpoNationalAccountFlag
{
get
{
return TpoNationalAccountFlag;
}
set
{
TpoNationalAccountFlag = value;
}
}
[DataMember]
public string tpoStoreAddress
{
get
{
return TpoStoreAddress;
}
set
{
TpoStoreAddress = value;
}
}
}
}
Это моя страница Service1.svc.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data.SqlClient;
namespace WcfServiceTPO
{
public class Service1 : IService1
{
public dataconnect[] GetData(string strLevelName) //Giving error on this line
{
var dataconnect= new List<dataconnect>();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString);
con.Open();
Service1 s = new Service1();
if (strLevelName == "4")
{
TpoStore();
SqlCommand cmd = new SqlCommand("select * from STORE", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
var dc = new dataconnect();
dc.tpoStoreid = dr[0].ToString();
dc.tpoStoreUnitCode = dr[1].ToString();
dc.tpostoreUnitShortName = dr[2].ToString();
dc.tpostoreUnitLongName = dr[3].ToString();
dc.tpoStoreTDLinx = dr[4].ToString();
dc.tpoRegionId = dr[5].ToString();
dc.tpoCityid = dr[6].ToString();
dc.tpoStoreClusterid = dr[7].ToString();
dc.tpoNationalAccountFlag = dr[8].ToString();
dc.tpoStoreAddress = dr[9].ToString();
dc.tpoLoadDate = dr[10].ToString();
dataconnect.Add(dc);
}
}
else if (strLevelName == "3")
{
SqlCommand cmd2 = new SqlCommand("select * from REGION", con);
SqlDataReader dr2 = cmd2.ExecuteReader();
while (dr2.Read())
{
var dc = new dataconnect();
dc.tpoRegionId = dr2[0].ToString();
dc.tpoRegionCode = dr2[1].ToString();
dc.tpoRegionShortName = dr2[2].ToString();
dc.tpoRegionLongName = dr2[3].ToString();
dc.tpoRegionTDLinx = dr2[4].ToString();
dc.tpoAccountID = dr2[5].ToString();
dc.tpoLoadDate = dr2[6].ToString();
//dataconnect.Add(dc);
SqlCommand cmd3 = new SqlCommand("select * from STORE where RegionId='" + dc.tpoRegionId.ToString() + "' ", con);
SqlDataReader dr3 = cmd3.ExecuteReader();
while (dr3.Read())
{
dc.tpoStoreid = dr3[0].ToString();
dc.tpoStoreUnitCode = dr3[1].ToString();
dc.tpostoreUnitShortName = dr3[2].ToString();
dc.tpostoreUnitLongName = dr3[3].ToString();
dc.tpoStoreTDLinx = dr3[4].ToString();
dc.tpoRegionId = dr3[5].ToString();
dc.tpoCityid = dr3[6].ToString();
dc.tpoStoreClusterid = dr3[7].ToString();
dc.tpoNationalAccountFlag = dr3[8].ToString();
dc.tpoStoreAddress = dr3[9].ToString();
dc.tpoLoadDate = dr3[10].ToString();
}
dataconnect.Add(dc);
dr3.Close();
}
dr2.Close();
}
else if (strLevelName == "2")
{
SqlCommand cmd1 = new SqlCommand("select * from accountmaster", con);
SqlDataReader dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
var dc = new dataconnect();
dc.tpoAccountID = dr1[0].ToString();
dc.tpoAccountCode = dr1[1].ToString();
dc.tpoAccountShortName = dr1[2].ToString();
dc.tpoAccountLongName = dr1[3].ToString();
dc.tpoAccountTDLinx = dr1[4].ToString();
dc.tpoChannelClassificationId = dr1[5].ToString();
dc.tpoLoadDate = dr1[6].ToString();
SqlCommand cmd2 = new SqlCommand("select * from REGION Where AccountID='" + dc.tpoAccountID.ToString() + "'", con);
SqlDataReader dr2 = cmd2.ExecuteReader();
while (dr2.Read())
{
dc.tpoRegionId = dr2[0].ToString();
dc.tpoRegionCode = dr2[1].ToString();
dc.tpoRegionShortName = dr2[2].ToString();
dc.tpoRegionLongName = dr2[3].ToString();
dc.tpoRegionTDLinx = dr2[4].ToString();
dc.tpoAccountID = dr2[5].ToString();
dc.tpoLoadDate = dr2[6].ToString();
//dataconnect.Add(dc);
SqlCommand cmd3 = new SqlCommand("select * from STORE where RegionId='" + dc.tpoRegionId.ToString() + "' ", con);
SqlDataReader dr3 = cmd3.ExecuteReader();
while (dr3.Read())
{
dc.tpoStoreid = dr3[0].ToString();
dc.tpoStoreUnitCode = dr3[1].ToString();
dc.tpostoreUnitShortName = dr3[2].ToString();
dc.tpostoreUnitLongName = dr3[3].ToString();
dc.tpoStoreTDLinx = dr3[4].ToString();
dc.tpoRegionId = dr3[5].ToString();
dc.tpoCityid = dr3[6].ToString();
dc.tpoStoreClusterid = dr3[7].ToString();
dc.tpoNationalAccountFlag = dr3[8].ToString();
dc.tpoStoreAddress = dr3[9].ToString();
dc.tpoLoadDate = dr3[10].ToString();
}
dr3.Close();
}
dataconnect.Add(dc);
dr2.Close();
}
dr1.Close();
}
else if (strLevelName == "1")
{
SqlCommand cmd = new SqlCommand("select * from CHANNELCLASS", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
var dc = new dataconnect();
dc.tpoChannelClassificationId = dr[0].ToString();
dc.tpoChannelClassificationCode= dr[1].ToString();
dc.tpoChannelClassificationShortName = dr[2].ToString();
dc.tpoChannelClassificationLongName = dr[3].ToString();
dc.tpoLoadDate = dr[4].ToString();
SqlCommand cmd1 = new SqlCommand("select * from accountmaster where ChannelClassificationId='" + dc.tpoChannelClassificationId.ToString() + "'", con);
SqlDataReader dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
dc.tpoAccountID = dr1[0].ToString();
dc.tpoAccountCode = dr1[1].ToString();
dc.tpoAccountShortName = dr1[2].ToString();
dc.tpoAccountLongName = dr1[3].ToString();
dc.tpoAccountTDLinx = dr1[4].ToString();
dc.tpoChannelClassificationId = dr1[5].ToString();
dc.tpoLoadDate = dr1[6].ToString();
SqlCommand cmd2 = new SqlCommand("select * from REGION Where AccountID='" + dc.tpoAccountID.ToString() + "'", con);
SqlDataReader dr2 = cmd2.ExecuteReader();
while (dr2.Read())
{
dc.tpoRegionId = dr2[0].ToString();
dc.tpoRegionCode = dr2[1].ToString();
dc.tpoRegionShortName = dr2[2].ToString();
dc.tpoRegionLongName = dr2[3].ToString();
dc.tpoRegionTDLinx = dr2[4].ToString();
dc.tpoAccountID = dr2[5].ToString();
dc.tpoLoadDate = dr2[6].ToString();
SqlCommand cmd3 = new SqlCommand("select * from STORE where RegionId='" + dc.tpoRegionId.ToString() + "' ", con);
SqlDataReader dr3 = cmd3.ExecuteReader();
while (dr3.Read())
{
dc.tpoStoreid = dr3[0].ToString();
dc.tpoStoreUnitCode = dr3[1].ToString();
dc.tpostoreUnitShortName = dr3[2].ToString();
dc.tpostoreUnitLongName = dr3[3].ToString();
dc.tpoStoreTDLinx = dr3[4].ToString();
dc.tpoRegionId = dr3[5].ToString();
dc.tpoCityid = dr3[6].ToString();
dc.tpoStoreClusterid = dr3[7].ToString();
dc.tpoNationalAccountFlag = dr3[8].ToString();
dc.tpoStoreAddress = dr3[9].ToString();
dc.tpoLoadDate = dr3[10].ToString();
}
dr3.Close();
}
dr2.Close();
}
dataconnect.Add(dc);
dr1.Close();
}
dr.Close();
}
return dataconnect.ToArray();
}
}
}
Мне нужно закорочить этот метод пожалуйста