wyrd Posted July 29, 2003 Posted July 29, 2003 (edited) Sort of hard for me to explain since I'm new to these concepts, but I'll try. DataTable uses a DataView. However the DataTable only lets you get it's DefaultView (you cannot set it), and DataView lets you get or set the DataTable in which it belongs to. I'm curious as to how the DataTable knows which DataView it belongs to. Is there an internal (for C#) reference for _dataView which DataView sets? Or is it handled differently? ie; // In DataView class. public DataTable { get { return _table; } set { // The old Table is no longer using this DataView. _table.DataView = null; _table = value; _table.DataView = this; // Note: DataView is an internal property. } } // In DataTable class. internal DataView { get { return _dataView; } set { _dataView = value; } } public DefaultView { get { return _dataView; } } I'm working on something similar. The ability to change dynamically how a class looks or is used based on a member class that it references. However I don't want the user to ruin the relationship by being able to set the Table's DefaultView to null or something else, which would leave the DataView.Table property pointing to a Table that doesn't use it. Or by setting the DataView.Table property to a Table, but not updating the Table.DefaultView, which would make the Table.DefaultView point to a DataView which it doesn't control. What's the best way to handle this? How does the Table/DataView relationship work under the hood? The internal example I gave above still seems prone a little prone to error. Thanks in advance. Edited July 29, 2003 by wyrd Quote Gamer extraordinaire. Programmer wannabe.
*Experts* Volte Posted July 29, 2003 *Experts* Posted July 29, 2003 Your way is probably the easiest. I don't think it's quite the method that the DataTable uses though (not exactly sure on that one). Quote
wyrd Posted July 29, 2003 Author Posted July 29, 2003 Hmm.. regardless of being easy, hard or whatever, are there other ways? I'm more concerned with doing it correctly. Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.