ASP.MVC db Find(), but with non-primary key parameter
How does one get a list of results by using a key that is not the primary
key? To be more specific, I have a composite primary key where I would
like to retrieve all the matches with one column's parameter.
I would think, in an ActionResult in the Controller, it's something like
tableModel tbmodel = db.tableModels.Find(i => i.partialPK == parameter)
but that's not the case, since Find() only works with the entire PK.
I declared my PKs in the entity model class as:
[Key]
[Column(Order = 0)]
public int PK1 { get; set; }
[Key]
[Column(Order = 1)]
public string PK2 { get; set; }
No comments:
Post a Comment