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


C# DataSet.GetType方法代码示例

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


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

示例1: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            if (this.Data != null)
            {
                context.HttpContext.Response.Clear();

                var oa = new Csla.Data.ObjectAdapter();
                var ds = new DataSet();

                oa.Fill(ds, this.TableName, this.Data);

                var xs = new System.Xml.Serialization.XmlSerializer(ds.GetType());

                context.HttpContext.Response.ContentType = "text/xml";

                xs.Serialize(context.HttpContext.Response.Output, ds);
            }
        }
开发者ID:WhiteIsland,项目名称:epiworx,代码行数:18,代码来源:XmlResult.cs

示例2: SaveTasks

        public void SaveTasks(IEnumerable<Task> tasks)
        {
            DataSet ds = new DataSet ();
            var dt = new DataTable ();

            dt.Columns.Add (new DataColumn ("Task_Deadline", Type.GetType ("System.DateTime")));
            dt.Columns.Add (new DataColumn ("Task_CreateDate", Type.GetType ("System.DateTime")));
            dt.Columns.Add (new DataColumn ("Task_Title", Type.GetType ("System.String")));
            dt.Columns.Add (new DataColumn ("Task_Description", Type.GetType ("System.String")));
            dt.Columns.Add (new DataColumn ("Task_Priority", Type.GetType ("LoganekPlaner.Priority")));
            dt.Columns.Add (new DataColumn ("Task_IsDone", Type.GetType ("System.Boolean")));
            ds.Tables.Add (dt);
            ds.Tables [0].TableName = "product";

            foreach (var task in tasks) {
                DataRow dr;
                dr = dt.NewRow ();

                if (task.Deadline.HasValue) {
                    dr ["Task_Deadline"] = task.Deadline;
                } else {
                    dr ["Task_Deadline"] = DBNull.Value;
                }

                dr ["Task_CreateDate"] = task.CreateDate;
                dr ["Task_Title"] = task.Title;
                dr ["Task_Description"] = task.Description;
                dr ["Task_Priority"] = task.Priority;
                dr ["Task_IsDone"] = task.IsDone;
                dt.Rows.Add (dr);
            }

            StreamWriter serialWriter;
            serialWriter = new StreamWriter (path);
            XmlSerializer xmlWriter = new XmlSerializer (ds.GetType ());
            xmlWriter.Serialize (serialWriter, ds);
            serialWriter.Close ();
            ds.Clear ();
        }
开发者ID:loganek,项目名称:loganek-planer,代码行数:39,代码来源:XMLDataStorage.cs

示例3: LoadAll

        /// <summary>
        /// Passes Partner Address data as a DataSet to the caller. Loads all available
        /// Addresses for the Partner.
        ///
        /// </summary>
        /// <param name="ADataSet">DataSet that holds a DataSet with a DataTable for the
        /// Person</param>
        /// <param name="APartnerKey">PartnerKey of the Partner for which Address data is to be
        /// loaded</param>
        /// <param name="AReadTransaction">Transaction for the SELECT statement
        /// </param>
        /// <returns>void</returns>
        public static void LoadAll(DataSet ADataSet, Int64 APartnerKey, TDBTransaction AReadTransaction)
        {
            PLocationTable LocationDT;
            PPartnerLocationTable PartnerLocationDT;

            PPartnerLocationAccess.LoadViaPPartner(ADataSet, APartnerKey, AReadTransaction);
            PLocationAccess.LoadViaPPartner(ADataSet, APartnerKey, AReadTransaction);

            // Apply security
            LocationDT = (PLocationTable)ADataSet.Tables[PLocationTable.GetTableName()];
            PartnerLocationDT = (PPartnerLocationTable)ADataSet.Tables[PPartnerLocationTable.GetTableName()];
            ApplySecurity(ref PartnerLocationDT, ref LocationDT);

            // make sure that location specific fields in PartnerLocationDT get initialized
            if (ADataSet.GetType() == typeof(PartnerEditTDS))
            {
                PartnerCodeHelper.SyncPartnerEditTDSPartnerLocation(LocationDT, (PartnerEditTDSPPartnerLocationTable)PartnerLocationDT);
            }

            if (TLogging.DL >= 9)
            {
                DebugLoadedDataset(ADataSet);
            }
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:36,代码来源:DataAggregates.PPartnerAddress.cs

示例4: LoadByPrimaryKey

        /// <summary>
        /// Passes Partner Address data as a DataSet to the caller. Loads the Address
        /// which is specified through ALocationKey.
        ///
        /// </summary>
        /// <param name="ADataSet">DataSet that holds a DataSet with a DataTable for the
        /// Person</param>
        /// <param name="APartnerKey">PartnerKey of the Partner for which Address data is to be
        /// loaded</param>
        /// <param name="ASiteKey">SiteKey of the Location for which Address data is to
        /// be loaded</param>
        /// <param name="ALocationKey">LocationKey of the Location for which Address data is to
        /// be loaded</param>
        /// <param name="AReadTransaction">Transaction for the SELECT statement
        /// </param>
        /// <returns>void</returns>
        public static void LoadByPrimaryKey(DataSet ADataSet, Int64 APartnerKey, Int64 ASiteKey, Int32 ALocationKey, TDBTransaction AReadTransaction)
        {
            PLocationTable LocationDT;
            PPartnerLocationTable PartnerLocationDT;

            PPartnerLocationAccess.LoadByPrimaryKey(ADataSet, APartnerKey, ASiteKey, ALocationKey, AReadTransaction);
            PLocationAccess.LoadByPrimaryKey(ADataSet, ASiteKey, ALocationKey, AReadTransaction);

            // Apply security
            LocationDT = (PLocationTable)ADataSet.Tables[PLocationTable.GetTableName()];
            PartnerLocationDT = (PPartnerLocationTable)ADataSet.Tables[PPartnerLocationTable.GetTableName()];
            ApplySecurity(ref PartnerLocationDT, ref LocationDT);

            // make sure that location specific fields in PartnerLocationDT get initialized
            if (ADataSet.GetType() == typeof(PartnerEditTDS))
            {
                PartnerCodeHelper.SyncPartnerEditTDSPartnerLocation(LocationDT, (PartnerEditTDSPPartnerLocationTable)PartnerLocationDT);
            }
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:35,代码来源:DataAggregates.PPartnerAddress.cs

示例5: SerializeDataSet3

		// bug #68007
		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.AreEqual (xml, result);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:57,代码来源:DataSetTest.cs

示例6: 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:nlhepler,项目名称:mono,代码行数:31,代码来源:DataSetTest.cs

示例7: SerializeTypedDataSet

        /// <summary>
        /// Serializes a Typed DataSet to a byte[] containing only the data for each DataTable (ie no infrastructure)
        /// </summary>
        /// <param name="dataSet">The Typed DataSet to serialize.</param>
        /// <returns>A byte[] containing the serialized data.</returns>
        /// <remarks>The DataSet must be Typed and not a plain DataSet. It must also not have had any 
        /// new columns/tables added to it. In either of these cases, use SerializeDataSet instead.</remarks>
        public static byte[] SerializeTypedDataSet(DataSet dataSet)
        {
            if (dataSet == null) throw new ArgumentNullException("dataSet");
            if (dataSet.GetType() == typeof(DataSet)) throw new ArgumentException("Is not a typed DataSet", "dataSet");

            return new FastSerializer().SerializeDataOnly(dataSet);
        }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:14,代码来源:AdoNetHelper.cs

示例8: DeserializeTypedDataSet

        /// <summary>
        /// Deserializes a Typed DataSet from a byte[] containing serialized data only.
        /// </summary>
        /// <param name="dataSet">The Typed DataSet to deserialize into.</param>
        /// <param name="serializedData">A byte[] containing the serialized data.</param>
        /// <returns>The same DataSet passed in.</returns>
        /// <remarks>The DataSet must be of the same type from which the serialized data was originally obtained.</remarks>
        public static DataSet DeserializeTypedDataSet(DataSet dataSet, byte[] serializedData)
        {
            if (dataSet == null) throw new ArgumentNullException("dataSet");
            if (serializedData == null) throw new ArgumentNullException("serializedData");
            if (dataSet.GetType() == typeof(DataSet)) throw new ArgumentException("Is not a typed DataSet", "dataSet");

            return new FastDeserializer().DeserializeDataSetDataOnly(dataSet, serializedData);
        }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:15,代码来源:AdoNetHelper.cs


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