当前位置:编程学习 > C#/ASP.NET >>

asp.net怎么选择数据库表、字段生成XML文档





我现在能生成一个表的XML
  但是我要是点击LEFT JOIN  或者 RIGHT JOIN 的时候  继续选择另一个表和字段 生成XML
就想页面的数据重新加载一下   求大神解决啊  
   或者有个项目列子最好啊 数据库 asp.net xml --------------------编程问答--------------------
public class ClientUIConfigSetting
{
    public ClientUIConfigSetting()
    {
        this.ClientUITypeSetCollection = new List<ClientUIType>();
    }
    public bool HasRemarks { get; set; }
}

--调用,转换成XML
edm.ClientUIConfigSetting = XmlUtility.ObjectToXml(dataModel.ClientUIConfigSetting, true, typeof(ClientUIConfigSetting));
edm.AllowAdHocInput = dataModel.AllowAdHocInput;




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using GlacierICR.Common.WorkDataTypes;

namespace GlacierICR.DAL
{
    public static class XmlUtility
    {
        public static string ObjectToXml(object obj, bool toBeIndented, Type type)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            UTF8Encoding encoding = new UTF8Encoding(false);
            XmlSerializer serializer = new XmlSerializer(type);
            MemoryStream stream = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(stream, encoding);
            writer.Formatting = (toBeIndented ? Formatting.Indented : Formatting.None);
            serializer.Serialize(writer, obj);
            string xml = encoding.GetString(stream.ToArray());
            writer.Close();
            return xml;
        }

        public static object XmlToObject(string xml, Type type)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }
            object o = null;
            XmlSerializer serializer = new XmlSerializer(type);
            StringReader strReader = new StringReader(xml);
            XmlReader reader = new XmlTextReader(strReader);
            try
            {
                o = serializer.Deserialize(reader);
            }
            catch (InvalidOperationException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                reader.Close();
            }
            return o;
        }

    }
}
--------------------编程问答--------------------
引用 楼主 xiaolaiba199468 的回复:




我现在能生成一个表的XML
  但是我要是点击LEFT JOIN  或者 RIGHT JOIN 的时候  继续选择另一个表和字段 生成XML
就想页面的数据重新加载一下   求大神解决啊  
   或者有个项目列子最好啊


解释一下呗  不太明白你写的是什么 --------------------编程问答--------------------
引用 1 楼 hdhai9451 的回复:
public class ClientUIConfigSetting
{
    public ClientUIConfigSetting()
    {
        this.ClientUITypeSetCollection = new List<ClientUIType>();
    }
    public bool HasRemarks { get; set; }
}

--调用,转换成XML
edm.ClientUIConfigSetting = XmlUtility.ObjectToXml(dataModel.ClientUIConfigSetting, true, typeof(ClientUIConfigSetting));
edm.AllowAdHocInput = dataModel.AllowAdHocInput;




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using GlacierICR.Common.WorkDataTypes;

namespace GlacierICR.DAL
{
    public static class XmlUtility
    {
        public static string ObjectToXml(object obj, bool toBeIndented, Type type)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            UTF8Encoding encoding = new UTF8Encoding(false);
            XmlSerializer serializer = new XmlSerializer(type);
            MemoryStream stream = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(stream, encoding);
            writer.Formatting = (toBeIndented ? Formatting.Indented : Formatting.None);
            serializer.Serialize(writer, obj);
            string xml = encoding.GetString(stream.ToArray());
            writer.Close();
            return xml;
        }

        public static object XmlToObject(string xml, Type type)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }
            object o = null;
            XmlSerializer serializer = new XmlSerializer(type);
            StringReader strReader = new StringReader(xml);
            XmlReader reader = new XmlTextReader(strReader);
            try
            {
                o = serializer.Deserialize(reader);
            }
            catch (InvalidOperationException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                reader.Close();
            }
            return o;
        }

    }
}
解释一下呗  不太明白你写的是什么 
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,