google-code-export / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
Other
0 stars 0 forks source link

DbMetal doesn't support Cardinality="One" #232

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is moved from Issue 228 Comment #3.

What steps will reproduce the problem?
1. Take a dbml file which has a //Association/@Cardinality='One' attribute 
value, such as the attached nwind.dbml file.

2. Generate source from it:

    DbMetal  /code:d.cs nwind.dbml
    sqlmetal /code:s.cs nwind.dbml

This is with the .NET SqlMetal tool.

3. Compare the output.  Of note here is the Categories.Products member:

.NET SqlMetal:

    private EntityRef<Products> _products = default(EntityRef<Products>);
    // ...
    [Association(...)]
    public Products Products {
        get {return this._products.Entity;}
        set {            
            Products previousValue = this._products.Entity;
            if (((previousValue != value) 
                || (this._products.HasLoadedOrAssignedValue == false)))
            {
                this.SendPropertyChanging();
                if ((previousValue != null))
                {
                    this._products.Entity = null;
                    previousValue.Categories = null;
                }
                this._products.Entity = value;
                if ((value != null))
                {
                    value.Categories = this;
                }
                this.SendPropertyChanged("Products");
            }
        }
    }

DbMetal instead generates an EntitySet<T>, not an EntityRef<T>:

    EntitySet<Products> _products;
    //...
    public EntitySet<Products> Products {
        get {return _products;}
        set {_products=value;}
    }

DbMetal should follow .NET SqlMetal here.

Original issue reported on code.google.com by jonmpr...@gmail.com on 9 Apr 2010 at 7:31

Attachments: