Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite foreign keys #36

Open
cdmdotnet opened this issue Oct 30, 2009 · 0 comments
Open

Composite foreign keys #36

cdmdotnet opened this issue Oct 30, 2009 · 0 comments

Comments

@cdmdotnet
Copy link

I've noticed that if a property is suffixed with an "x" the logic inside the foreign keys doesn't include the "x" - example generated code below.

    #region Properties

    partial void OnAUDIT_TYPEXChanging(int value);
    partial void OnAUDIT_TYPEXChanged();

    private int _AUDIT_TYPEX;
    public int AUDIT_TYPEX { 
        get{
            return _AUDIT_TYPEX;
        } 
        set{
            this.OnAUDIT_TYPEXChanging(value);
            this.SendPropertyChanging();
            this._AUDIT_TYPEX = value;
            this.SendPropertyChanged("AUDIT_TYPEX");
            this.OnAUDIT_TYPEXChanged();
        }
    }
    #region Foreign Keys
    public IQueryable<COMPANY_AUDIT_TYPE> COMPANY_AUDIT_TYPES
    {
        get
        {
              var db=new DB();
              return from items in db.COMPANY_AUDIT_TYPES
                   where items.AUDIT_TYPE == _AUDIT_TYPE // ERROR HERE NO "X" SUFFIX, SHOULD BE _AUDIT_TYPEX
                   select items;
        }
    }

Also the generators completly die when they reach composite keys. Instead of generating ONE property they generate four and start mixing the comparsomes, which can also leed to string == int type comparisomes. see generated code below

    #region Foreign Keys
    public IQueryable<EMPLOYEE> EMPLOYEES
    {
        get
        {
              var db=new DB();
              return from items in db.EMPLOYEES
                   where items.COMPANY_ID == _COMPANY_ID
                   select items;
        }
    }

    public IQueryable<EMPLOYEE> EMPLOYEES1
    {
        get
        {
              var db=new DB();
              return from items in db.EMPLOYEES
                   where items.EMPLOYEE_NUM == _COMPANY_ID
                   select items;
        }
    }

    public IQueryable<EMPLOYEE> EMPLOYEES2
    {
        get
        {
              var db=new DB();
              return from items in db.EMPLOYEES
                   where items.COMPANY_ID == _EMPLOYEE_NUM
                   select items;
        }
    }

    public IQueryable<EMPLOYEE> EMPLOYEES3
    {
        get
        {
              var db=new DB();
              return from items in db.EMPLOYEES
                   where items.EMPLOYEE_NUM == _EMPLOYEE_NUM
                   select items;
        }
    }

ideally it would just generate

    #region Foreign Keys
    public IQueryable<EMPLOYEE> EMPLOYEES
    {
        get
        {
              var db=new DB();
              return from items in db.EMPLOYEES
              where items.COMPANY_ID == _COMPANY_ID && EMPLOYEE_NUM == _EMPLOYEE_NUM
                   select items;
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant