一般在WCf数据大数据是 List集合 或者 Json。
public DataTable GetProperitybyModelCode(string modelCode) { using (var entity = new USERRIGHTEntities()) { //查询对应的表名和表的ID
var queryResult = (from fx in entity.T_ModelInfo join tp in entity.T_ModelProperties on fx.F_ModelCode equals tp.F_ModelCode where fx.F_ModelCode == modelCode select new { TableName = tp.F_ProperieTable, ProperityCode = tp.F_ProperieCode }).FirstOrDefault();
if (queryResult != null && queryResult.TableName != null) { var retVal = new DataTable(); var entityConn = (EntityConnection)entity.Connection; var sqlConn = (SqlConnection)entityConn.StoreConnection; var cmdReport = new SqlCommand(string.Format("select * from [{0}] where F_ProperieCode={1}", queryResult.TableName, queryResult.ProperityCode), sqlConn); var daReport = new SqlDataAdapter(cmdReport); using (cmdReport) { daReport.Fill(retVal); } retVal.TableName = queryResult.TableName;//这里一定要写个表名 不然在返回客户端的时候 会报个错。 return retVal; } } return null; }
客户端调用:
var client=new BpjdqOperatorServiceClient(SIMUBUSINESSLOGICDATA.WebServiceApp.WsHttpBinding(),SIMUBUSINESSLOGICDATA.WebServiceApp.BpjdqEndpoingAddress()); client.BeginGetProperitybyModelCode("0001", delegate(IAsyncResult asyncResult) { var query = client.EndGetProperitybyModelCode(asyncResult); if (query.Rows.Count>0) { foreach (var item in query.Rows) { } } }, null);