Thank you for reading! I'm getting a list of objects (from a dbcontext), then I created a method to pass this list to a Local Function, the method accepts the list but when I try to loop, instead of being able to show the content of my object members I get an error saying: "'T' does not contain a definition for 'Id' and no accessible extension method 'Id' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?) " And this problem is not only with Id, I can't access any of the properties, please check the code: would you please help me find what I am missing? thank you for your advice.
- public IActionResult Racks()
- {
-
- List<OldRackAustin> mylist = db.OldRacksAustin.ToList<OldRackAustin>();
-
- ProcessMyList(mylist);
-
- void ProcessMyList<T>( List<T> list)
- {
-
- foreach (T item in list)
- {
- Debug.WriteLine(item.Id); /* PROBLEMATIC LINE */
- }
-
- }
-
- return Json("done");
- }
And the DBcontext entity (object) looks like...
- [Table("OLD-Racks-Austin")]
- public class OldRackAustin
- {
- [Key]
- public int Id { get; set; }
- public string Rack_Type { get; set; }
- public string Serial_Number { get; set; }
- public short Pages { get; set; }
- public int? Rack_Capacity { get; set; }
- public string Status { get; set; }
- public string Type { get; set; }
- public string Subtype { get; set; }
-
- }