-1

i'm using DataTable to transfer through WCF channel. I know, thats a bad solution, however it's a necessary by system design.

So, i've encountered a problem... In this code, as you can see, i'm populating datatable with dataadapter.

using (var session = DatabaseManager.SessionFactory.OpenSession())
{
    using (var conn = session.Connection as MySqlConnection)
    {
        var adapter = new MySqlDataAdapter(string.Format("SELECT * FROM {0}", dt.TableName), conn);
        adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
        adapter.Fill(dt);
        dt.AcceptChanges();
    }
}

When i checking DataTable constraints property, on server-side, right after filling, it's filled. And it's ok.

BUT! When datatable comes to client side, constraints vanished. AcceptChanges not working here for me...

BaseDataTable code snippet:

    public class BaseDataTable : DataTable
{
    public string TableDescription { get; set; }
    public DateTime ProcessTime { get; set; }
    public bool IsEditable { get; set; }

    public BaseDataTable()
    {

    }

    public BaseDataRow GetNewRow()
    {
        BaseDataRow row = (BaseDataRow)NewRow();

        return row;
    }

    public class BaseDataRow : DataRow
    {
        internal BaseDataRow(DataRowBuilder builder) : base(builder) { }
    }
}

**BUT! When i'm sendind to client NOT A CUSTOM TYPED DataTable, but a common DataTable filled with DataAdapter all properties filled properly**

Already checked: Set DataTable RemotingFormat = SerializationFormat.Binary/Xml -- No effect

Jesse
  • 79
  • 1
  • 8
  • http://stackoverflow.com/questions/12702/net-returning-datatables-in-wcf might helpe DataSet Solution – Ashok Rathod Aug 20 '14 at 11:10
  • not for me...there are a bit different issue...i don't have errors at all...Constraints property, that comes inside datatable from server is empty – Jesse Aug 20 '14 at 11:45

1 Answers1

0

Make sure DataTable is attributed as DataContract. can you show how you are defining dt ?

Please make sure that dt which is of type DataTable is exposed as DataContract.

Hope it helps.

Debug_mode
  • 80
  • 6
  • it says: Type 'BaseDataTable' cannot be IXmlSerializable and have DataContractAttribute attribute – Jesse Aug 20 '14 at 14:24