Change the generated EntitySet name

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Paul_Ibis
Posts: 3
Joined: Wed 22 Jan 2020 03:02

Change the generated EntitySet name

Post by Paul_Ibis » Fri 14 Feb 2020 00:08

I have a database that has two relationships between the same two tables.
In LinqConnect in the "Model Naming" properties, I have everything unchecked for "Class and Method Names" and "Class Properties' Names". When the model is created it creates two associations, with names of "PosTransaction_PosTransItem1" and "PosTransaction_PosTransItem"
The following code is generated :

Code: Select all

[Devart.Data.Linq.Mapping.Association(Name="PosTransaction_PosTransItem", Storage="_PosTransItem_Fk_PosTransaction_Redeem", ThisKey="PosTransID", OtherKey="Fk_PosTransaction_Redeem", DeleteRule="NO ACTION")]
        public EntitySet<PosTransItem> PosTransItem_Fk_PosTransaction_Redeem
        {
            get
            {
                return this._PosTransItem_Fk_PosTransaction_Redeem;
            }
            set
            {
                this._PosTransItem_Fk_PosTransaction_Redeem.Assign(value);
            }
        }
and

Code: Select all

[Devart.Data.Linq.Mapping.Association(Name="PosTransaction_PosTransItem1", Storage="_PosTransItem_PosTransID", ThisKey="PosTransID", OtherKey="PosTransID", DeleteRule="NO ACTION")]
        public EntitySet<PosTransItem> PosTransItem_PosTransID
        {
            get
            {
                return this._PosTransItem_PosTransID;
            }
            set
            {
                this._PosTransItem_PosTransID.Assign(value);
            }
        }
My question : Is it possible to control the naming of the entity set (e.g. PosTransItem_PosTransID and PosTransItem_Fk_PosTransaction_Redeem) ? When the model is created using SQLMetal to create LinqtoSQL, the EntitySet name is just "PosTransItem", so elsewhere in code you would do something like

Code: Select all

posTrans.PosTransItem.Where(p=> p......)
. In this case, it would now be

Code: Select all

posTrans.PosTransItem_PosTransID.Where(p=> p......)
which just looks a bit clumsy.

Paul_Ibis
Posts: 3
Joined: Wed 22 Jan 2020 03:02

Re: Change the generated EntitySet name

Post by Paul_Ibis » Fri 14 Feb 2020 01:16

OK, so I found out how to change the naming - it's in the "Association Editor" if you double click on the appropriate association.

Post Reply