How to change DataSet schema in C # ASP.Net Runtime

I would like to know how to change the schema of the DataSet at runtime

+1


source to share


2 answers


Is it typed or untyped DataSet

? For typed ones, this is probably not a good idea to start. But for untyped, just manipulate tables Columns

, etc., or add / remove tables / associations. Was there anything in particular that was painful? Or do you mean an adapter circuit?



Personally, I rarely use it DataSet

, preferring standard POCO classes for entities (maybe with an ORM like LINQ-to-SQL / Entity Framework / NHibernate). But some people like ...

+1


source


We had a similar problem. Here's what we did. The database server stores the time in GMT. And the web service returned all GMT. So, in C #, we set the timezone to UTC and display using localization.



        DataSet newDset = srcTable.Clone();
        DataTable dTable = newDset.Tables[0];

        for (int j = 0; j < dTable.Columns.Count; j++)
        {
            if (dTable.Columns[j].DataType.ToString() == "System.DateTime")
            {
                dTable.Columns[j].DateTimeMode = DataSetDateTime.Utc;
            }
        }

      

0


source







All Articles