|
|
Re: [qvto] One-to-Many Mappings [message #107048 is a reply to message #107006] |
Wed, 24 June 2009 12:36 |
Radomil Dvorak Messages: 249 Registered: July 2009 |
Senior Member |
|
|
Hi Rhett,
There is a straightforward pattern for one-to-many mapping, expressed
directly in the operation signature using a collection return type.
You can use something like:
mapping Model::onetoMany() : Collection(Table) {
init {
result := Sequence {
object Table {},
object Table {}
};
}
}
Subsequent mapping calls on the same source object will retrieve
all the objects created in the first mapping call which actually
realized the one-to-many mapping.
Regards,
/Radek
On Tue, 23 Jun 2009 20:17:06 +0200, Rhett Hudson <rhudson@annapmicro.com>
wrote:
> I have a source model that contains an object whose data can cause
> multiple objects to be instantiated in the target mapping. The source
> model essentially represents a series of target model objects using a
> 'start' and 'stop' number. The mapping of the source element to the
> target elements is potentially one-to-many.
>
> I've tried several approaches to achieving this end. I've tried using a
> while construct to loop around an object construct, but that appears to
> simply create one object and update it even if I use +=. I've tried some
> select/collect structures, but they produce collections that I then
> can't iterate over to add to my target model.
>
> Is there a viable pattern for solving this sort of problem?
>
> Thanks,
> Rhett
>
|
|
|
Powered by
FUDForum. Page generated in 0.03993 seconds