当前位置: 首页>>代码示例>>C#>>正文


C# DataSet.GetType方法代码示例

本文整理汇总了C#中DataSet.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet.GetType方法的具体用法?C# DataSet.GetType怎么用?C# DataSet.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataSet的用法示例。


在下文中一共展示了DataSet.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SerializeDataSet2

        public void SerializeDataSet2()
        {
            DataSet quota = new DataSet("Quota");

            // Dimension
            DataTable dt = new DataTable("Dimension");
            quota.Tables.Add(dt);

            dt.Columns.Add("Number", typeof(int));
            dt.Columns["Number"].AllowDBNull = false;
            dt.Columns["Number"].ColumnMapping = MappingType.Attribute;

            dt.Columns.Add("Title", typeof(string));
            dt.Columns["Title"].AllowDBNull = false;
            dt.Columns["Title"].ColumnMapping =
            MappingType.Attribute;

            dt.Rows.Add(new object[] { 0, "Hospitals" });
            dt.Rows.Add(new object[] { 1, "Doctors" });

            dt.Constraints.Add("PK_Dimension", dt.Columns["Number"], true);

            quota.AcceptChanges();

            XmlSerializer ser = new XmlSerializer(quota.GetType());

            StringWriter sw = new StringWriter();
            ser.Serialize(sw, quota);

            DataSet ds = (DataSet)ser.Deserialize(new StringReader(sw.ToString()));
        }
开发者ID:dotnet,项目名称:corefx,代码行数:31,代码来源:DataSetTest.cs

示例2: SerializeDataSet3

        public void SerializeDataSet3()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?><DataSet><xs:schema id=""Example"" xmlns="""" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata""><xs:element name=""Example"" msdata:IsDataSet=""true""><xs:complexType><xs:choice maxOccurs=""unbounded"" minOccurs=""0""><xs:element name=""Packages""><xs:complexType><xs:attribute name=""ID"" type=""xs:int"" use=""required"" /><xs:attribute name=""ShipDate"" type=""xs:dateTime"" /><xs:attribute name=""Message"" type=""xs:string"" /><xs:attribute name=""Handlers"" type=""xs:int"" /></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata"" xmlns:diffgr=""urn:schemas-microsoft-com:xml-diffgram-v1""><Example><Packages diffgr:id=""Packages1"" msdata:rowOrder=""0"" ID=""0"" ShipDate=""2004-10-11T17:46:18.6962302-05:00"" Message=""Received with no breakage!"" Handlers=""3"" /><Packages diffgr:id=""Packages2"" msdata:rowOrder=""1"" ID=""1"" /></Example></diffgr:diffgram></DataSet>";

            DataSet ds = new DataSet("Example");

            // Add a DataTable
            DataTable dt = new DataTable("Packages");
            ds.Tables.Add(dt);

            // Add an ID DataColumn w/ ColumnMapping = MappingType.Attribute
            dt.Columns.Add(new DataColumn("ID", typeof(int), "",
                MappingType.Attribute));
            dt.Columns["ID"].AllowDBNull = false;

            // Add a nullable DataColumn w/ ColumnMapping = MappingType.Attribute
            dt.Columns.Add(new DataColumn("ShipDate",
                typeof(DateTime), "", MappingType.Attribute));
            dt.Columns["ShipDate"].AllowDBNull = true;

            // Add a nullable DataColumn w/ ColumnMapping = MappingType.Attribute
            dt.Columns.Add(new DataColumn("Message",
                typeof(string), "", MappingType.Attribute));
            dt.Columns["Message"].AllowDBNull = true;

            // Add a nullable DataColumn w/ ColumnMapping = MappingType.Attribute
            dt.Columns.Add(new DataColumn("Handlers",
                typeof(int), "", MappingType.Attribute));
            dt.Columns["Handlers"].AllowDBNull = true;

            // Add a non-null value row
            DataRow newRow = dt.NewRow();
            newRow["ID"] = 0;
            newRow["ShipDate"] = DateTime.Now;
            newRow["Message"] = "Received with no breakage!";
            newRow["Handlers"] = 3;
            dt.Rows.Add(newRow);

            // Add a null value row
            newRow = dt.NewRow();
            newRow["ID"] = 1;
            newRow["ShipDate"] = DBNull.Value;
            newRow["Message"] = DBNull.Value;
            newRow["Handlers"] = DBNull.Value;
            dt.Rows.Add(newRow);

            ds.AcceptChanges();

            XmlSerializer ser = new XmlSerializer(ds.GetType());
            StringWriter sw = new StringWriter();
            ser.Serialize(sw, ds);

            string result = sw.ToString();

            Assert.Equal(xml, result);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:56,代码来源:DataSetTest.cs

示例3: MetadataLink

 public string MetadataLink(DataSet dataset)
 {
     return String.Format("<span class=\"metadata-link\">{0}</span>", Link(
         "View Metadata",
         DictHelper.Create(
             "controller=metadata",
             "action=view",
             "querystring=owner=" + dataset.Id.ToString() +
             "&type=" + dataset.GetType().Name
     )));
 }
开发者ID:nbadw,项目名称:sjr_atlas,代码行数:11,代码来源:AtlasHelper.cs


注:本文中的DataSet.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。