开发者

NHibernate, WCF, WPF architectural issues

I want to display a bunch of different data objects that I have using WPF. These data objects vary in data. They have common properties, but they also have some differing properties. There will be a "master" class that references these entities. Each master class can have one of each of these data types.

I'm finding it difficult to design them even on a database level. Should I have one table per data object, thereby making it easy to get the data using NHibernate (just reference one of these entities). This makes it quite difficult to consume using WCF though. If I'm wanting to display this data in WPF, I'll probably need a collection of some variety, and that's what I don't have.

I could put all data types into the same table and have a multi-column unique constraint on the 开发者_运维百科owner id and data type id. But then I may have null properties in my entities, and it would also be hard to display in the UI. It would also complicate editing the entities, as I'd have to mindful of which properties the user can and can't edit.

I guess visually, the entities would look like this in the first way:

 public class Master
{
    int Id
    DataType1 Data1
    DataType2 Data2
}

public class DataType1
{
    int Id
    string SomeString
    string AnotherString
}

public class DataType2
{
    int Id
    string SomeString
    string DifferentString
}

And this in the second way:

public class Master
    {
        int Id
        List<DataType> Types
    }

public class DataType
{
   int Id
   string SomeString
   string AnotherString
   string DifferentString
}

So which would be the best way? Or is there a different way that's better than both (there probably is)?


It is really depend on your business case as it is not such an architectural issue. If you have known number of DataType-s do static (one to one) reference (first example).

If you have unknown or dynamic number of the DataType-s you have no other option than to make these DataType-s as a list in your "Master" object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜