Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to establish association from one class to many classes

$
0
0

For instance, you have a class for File. This class will be used in more than one BO. Each BO would then have a listview of Files that are attached to the particular class.
To accomplish this, you can create a super class, say DomainObjectBase and then establish a one-to-many relationship between the File class. After that you can derive your BOs from the DomainObjectBase class and they will automatically get the parent's relationships.

Question Comments

Added By: Martin D. at: 6/21/2014 11:01:22 AM    

Is it possible - to also associate with different representations of "File" ?
So that DomainObject1 -> get's a collection of GetCollection<MyFile>("files")
and domainObject2 -> Get's a collection of GetCollection<PngFile>("files") ?

Added By: Dennis (DevExpress Support) at: 6/23/2014 6:15:09 AM    

I see several possible solutions for this:

1. Use the current code as is, create File descendants and then customize the New Action depending on the selected type to allow creation only of required file types. See also the How to display details collections with descendant classes filtered by object type in a DetailView  example for some example code on creating descendants and presenting them in the UI (this is not exactly what you are looking for, but it demonstrates a part of the described solution).
2. Do not have a common association and rather implement specific associations for each object and file type.

 

Added By: Paul Kubb at: 4/17/2016 8:48:18 AM    Association with abstract class?
are you sure this code is usable?

Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>