I am writing an application where we will need to expand a basic unit in many things (like employees, vehicles e.t.c) ). This design is such that there is a second table with an entity table and one type of specific values like the employee will have an ID number, but the registration number of a vehicle will be.
I got class unit data in context but there is a problem with casting in my repository. ? What is the correct way to do this?
Public category cAccountEmployee: cAccountEntity {public string ID_NUMBER {{try to get back {return this.cAccountEntityValues.Single (E => gt; e.type == 1 ) .Value; } Hold (exception) {return ""; }} Set {try {this.cAccountEntityValues.Single (e = & gt; e.type == 1) .value = value; } Hold (exception) {this.cAccountEntityValues.Add (new cAccountEntityValue () {accountentity_id = this.id, cAccountEntity = this, type = 1, value = value}); }}}
}
Then in my store (there is no heir)
public IEnumerable & LT; CAccountEmployee & gt; All (integer accountholder_id) {db.cAccountEntities.Where to return (E => gtc: e.accountholder_id == accountholder_id) .OrderBy (a => a.name) .Cast & LT; CAccountEmployee & gt; (); } Public cAccountEmployee single (id) {return db.cAccountEntities.Single (a => a.id == ID) as cAccountEmployee; }
Artists fail in a single method and so I get null back. Is it my understanding that you can not define explicit or implied operators or base class? How can I still retrieve the result of Base Class Linq in the inherited employee category, as I still maintain my DB State so that I submit the changes?
LINQ-to-SQL:
- Discrimination on a table (not suitable after your data is not uniform)
- Base-class / multi-table (not that it is not supported in DBML - Only if you write class manually)
LINQ-to-SQL does not support multi-table inheritance (i.e. with data from more than one table One object) does the unit framework, but is more complex; T & gt; and .ofType & LT; T & gt; You can
.ast
in FE to subtype / cast to filter
you can.
Personally, I will not do this like this ... I have different classes for different types, and use data-reference correctly, using different tables per type:
Public IEnumerable & lt; Employee & gt; All (int extraordonder_id) {Return DB Employees. Where (E = & gt; E.ContholddId == Exclained_ID). Orderbird (A = AAAN); } Public Employee Single (Ent ID) {Return db.Employees.Single (a => a.id == ID); }
So - can you explain that cAccountEntity
is here?
Comments
Post a Comment