var adds1 = getoneCityList.Select(l => { return new { YDCode = l.YDCode, SJQH = l.SJQH }; });
var jStr1 = JsonConvert.SerializeObject(new { root = new { li = adds1 } }); var xml1 = JsonConvert.DeserializeXmlNode(jStr1); var dtOut3 = new TB_DomainAreaDAL().GetRegionalismList(xml1); public DataTable GetRegionalismList(System.Xml.XmlDocument list) { string xml;//SJQH YDCode using (System.IO.StringWriter sw = new System.IO.StringWriter()) { System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(list.GetType()); xs.Serialize(sw, list); xml = sw.ToString(); } StringBuilder strb = new StringBuilder(); strb.AppendLine("DECLARE @xml XML = @xmlData;"); strb.AppendLine(@"select distinct T.c.value('SJQH[1]','nvarchar(50)') SJQH, T.c.value('YDCode[1]','nvarchar(50)') YDCode,a.Regionalism FROM TB_DomainArea AS a INNER JOIN @xml.nodes('/root/li') T(c) ON a.AreaCode=T.c.value('SJQH[1]','nvarchar(300)')"); var dt = DbHelperSQL.Query(SqlHelper.ConnectionStringLocalTransaction2Read, strb.ToString(), new SqlParameter("@xmlData", SqlDbType.Xml) { Value = xml }).Tables[0]; return dt; }