This is a migrated thread and some comments may be shown as answers.

Generating tables

1 Answer 133 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christian
Top achievements
Rank 1
Christian asked on 12 Jan 2009, 03:31 PM
Hi,
I have the following problem:
In the data model, there are three classes 'order ','orderitems' and 'product '. Each order has an unlimited number of order positions. Each position item has exactly one entry for a product.
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
 
namespace OrderTest  
    {  
    [Telerik.OpenAccess.Persistent()]  
    public class Order  
        {  
        public Order(){}  
 
        private string ordername;  
        private IList<OrderItem> orderitems;  
 
        public string Ordername  
            {  
            get 
                {  
                return this.ordername;  
                }  
            set 
                {  
                this.ordername = value;  
                }  
            }  
          
        }  
 
    [Telerik.OpenAccess.Persistent()]  
    public class Product  
        {  
        public Product()  
            {  
            }  
 
        private string productname;  
 
        [Telerik.OpenAccess.FieldAlias("productname")]  
        public string Productname  
            {  
            get 
                {  
                return this.productname;  
                }  
            set 
                {  
                this.productname = value;  
                }  
            }  
        }  
 
    [Telerik.OpenAccess.Persistent()]  
    public class OrderItem  
        {  
 
        private Product ordercontent;  
        private int orderposition;  
 
        public OrderItem(){}  
 
        public Product OrderContent  
            {  
            get 
                {  
                return this.ordercontent;  
                }  
            set 
                {  
                this.ordercontent = value;  
                }  
            }  
 
        public int OrderPosition  
            {  
            get 
                {  
                return this.orderposition;  
                }  
            set 
                {  
                this.orderposition = value;  
                }  
            }  
        }  
      
    }  
 


The order positions for a order will have row number  (orderposition). When creating the classes, the mapper, however, produced four tables: ordr, ordr_order_item, order_item and product.
My problem is that when you delete a order position in the connection table between order and order the item correctly processed. The table with the order position itself, however, is not changed and therefore contains records that are no longer connected to a record in the order table.
My question is: How can I make the mapper just the three required to create tables.

For suggestions, I would be grateful.
Christian

1 Answer, 1 is accepted

Sort by
0
Accepted
Zoran
Telerik team
answered on 13 Jan 2009, 12:11 PM
Hi Christian,

  When having one-to-many relation in your persistent model there are to ways to create the database-schema. The default is by creating a join-table, but if you want to avoid that you have to disable it from the forward mapping wizard. Since the join table is created because of the orderitems field of the Order class, you need to expand the tree node for Order in the forward mapping wizard and select orderitems. The new content of the form contains a group box called "Relationship". It has a checkbox "Join Table" within it and you need to uncheck it so that a join table for Order and Orderitems would not be created or used.

I hope this will help you achieve the goals planned for your project.

Best wishes,
Zoran
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Databases and Data Types
Asked by
Christian
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Share this question
or