shared, read-only data

G

Guest

Hi, NG!
Is there any way to share DataTable "definitions" across multiple DataSets
in the DataSet designer? To make it more clear I need to have a "master"
DataSet that contains unrelated tables (that are read-only at runtime,
reference lists...) At runtime an instance of this DataSet will be globally
accessible. Is it possible to access DataTables in this "master" DataSet
from some other DataSets that have very different functionalities, but need
to refer to some of these read-only lists?
So, the needs are actually two: share DataTables between DataSets in the
DataSet designer and second, at run-time, make DataTables in different
DataSets access a single copy of data, i.e. the tables in a "master"
object/DataSet.

To make it even more clear there's a need for some read-only data across the
entire application... and the ability to incorporate these tables in
different scenarios/areas of the application, work with the
relations/constraints in the designer... designer-aided databindings etc...
The single DataSet per application solution would be quite messy...

I guess this is a common need, but I cannot figure a way to implement it...
I'm working with C# in VS 2005 Standard Edition.

Any suggestion is very appreciate. Thanks in advance.





pax
 
J

Jesús López

Although It would be very cool, I really don't think there is a way to
fullfill all your requirements. However when I need to share data along the
entire application (a Windows application). I do the following:

(1) create a typed dataset (DataSetMaster) with the datatables I need to
share
(2) Implement the singleton pattern on this dataset
(3) Create a new dataview class inherited form dataview for each datatable
in DataSetMaster. Something like this:

Public Class DataViewSomeTable
Inherits DataView

Public Sub New()
MyBase.New(DataSetMaster.SingletonInstance.SomeTable)
End Sub
End Class

In this way, when I drag a DataViewSomeTable from the toolbox and drop onto
some design surface, the DataViewSomeTable1 instance of DataViewSomeTable is
referencing always the same data, no matter how many instances you create,
all instances of DataViewSomeTable references the same DataTable instance.
And additionally I am allowed to perform design time databinding. That's all
I have got, sorry.

Another techique I have used is the following:
(1) the same as above
(2) the same as above
(3) Create a new component named ListSourceDatasetMaster. This componet
inherits from Component and implements IListSource. To implement IListSource
it relies on DataSetMaster.SingletonInstance.

Public Class ListSourceDatasetMaster
Inherits Component
Implements System.ComponentModel.IListSource


Public ReadOnly Property ContainsListCollection() As Boolean Implements
System.ComponentModel.IListSource.ContainsListCollection
Get
Return DirectCast(DatasetMaster.SingletonInstance,
System.ComponentModel.IListSource).ContainsListCollection
End Get
End Property

Public Function GetList() As System.Collections.IList Implements
System.ComponentModel.IListSource.GetList
Return DirectCast(DatasetMaster.SingletonInstance,
System.ComponentModel.IListSource).GetList()
End Function
End Class

In this way when I drag a ListSourceDatasetMaster from the toolbox into a
design surface, I get a desing time bindable object that always references
the same data. This data is the singleton instance of DatasetMaster.

Regards from Madrid (Spain)

Jesús López
VB MVP
 
G

Guest

Not sure if this applies to your application, but I had to work with read
only data (for drop downs), so it might work.

1. Create the definitions dataset of many datatables, this is the read only.
2. Create a wrapper to query this by table name.

On the page, we fill in the drop down with the values from the "read only
cached" data tables (the read only dataset). To get defaults, we pull the
corresponding value for the record from the "non-read only" dataset that
applies to the particular record being displayed.

This works in this instance, as the only dropdown value necessary for the
dynamic data is the value currently selected. The wrapper ensures that the
user does not change the read only data, even if he wanted to, as it pushes
out a deep copy, so it solves that need, as well.

The one thing this does not do is tightly link the chosen value to the
definition table. If this is a requirement of your app, this idea will not
work.

Hope I was clear on this one. :)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
G

Guest

Well, thanks a lot, Jesus from Madrid (Spain :)
It seems we're getting something... I'm glad to see that my requirements are
not completely stupid :)
But, now for you and for all around, how can I get a certain 'thing' (a
class) to appear on the design surface of the DataSet designer, a DataSet
that is created by the wizard, using a Database source type?
What can I do to make a class appear on the DataSet toolbox or at list
directly on the design surface? I need to work there... I need to describe
relations and stuff... Shouldn't we have at least all the 'DataTable-like'
classes in the project listed in the toolbox, in the DataSet tab?
Any suggestions?

Thanks.



pax
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top