Esempio n. 1
0
        /// <summary>
        /// 获取存取在DataSet的数据的xml表现形式
        /// </summary>
        /// <param name="dataSet">数据源DataSet</param>
        /// <param name="mappingType">映射DataColumn的方式</param>
        /// <param name="xmlWriteMode">指定如何从DataSet写入xml数据和关系架构</param>
        /// <returns>DataSet中的数据的xml表现形式</returns>
        public static string GetXml(this DataSet dataSet, MappingType mappingType, XmlWriteMode xmlWriteMode)
        {
            FrameDataSetExtends.SetDataSetColumnElementToAttribute(dataSet, mappingType);
            MemoryStream ms  = new MemoryStream();
            XmlDocument  dom = new XmlDocument();

            try
            {
                dataSet.WriteXml(ms, xmlWriteMode);
                ms.Flush();
                ms.Seek(0, SeekOrigin.Begin);
                dom.Load(ms);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ms.Close();
            }

            return(dom.InnerXml);
        }
Esempio n. 2
0
 /// <summary>
 /// 获取存取在DataSet的数据的xml表现形式
 /// </summary>
 /// <param name="dataSet">数据源DataSet</param>
 /// <param name="mappingType">列的映射方式</param>
 /// <returns>DataSet中的数据的xml表现形式</returns>
 public static string GetXml(this DataSet dataSet, MappingType mappingType)
 {
     FrameDataSetExtends.SetDataSetColumnElementToAttribute(dataSet, mappingType);
     return(dataSet.GetXml());
 }