开发者

SubSonic 3 and composite foreign keys

I'm current evaluating SubSonic 3 for use with a legacy DB - IE very little ability to change the current structure.

Long story short SubSonic 2 handled our composite foreign keys pretty well - however we're looking for something that will providew linq and all the rest that goes along with SS3.

So far I开发者_运维百科've found that SS3 using both the ActiveRecord.tt and Classes.tt T4 templates I get very very messed up relationships.

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. 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;
        }
    }

Does SS3 properly support composite foreign keys, my results lead me to fear that it does not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜