0

I have requirment to get the data from context object using reflection concept in EF .NET Core. For Ex:

_context.TblClaim.Take(5).ToArray() 

In the above line of code I Need to pass TblClaim using reflection, then I need to get the top 5 records, Please someone help me on this. Note: If you need any info please let me know.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132
  • What is you are passing actually? Can you please show an example of parameters? Where requirement of using reflection comes from? – Guru Stron May 04 '22 at 13:17
  • ```foreach (var propertyInfo in _context.GetType().GetProperties().Where(p => p.PropertyType.Name.StartsWith("DbSet"))) { string tableName = "TblClaim"; tableNames.Add(propertyInfo.Name); //var tbname = _context.Set(propertyInfo.Name).Take(5).ToList(); }``` If you see the above code, I will all DbSet objects, then I need to get few records from each DbSet object – Chenchu babu May 04 '22 at 13:20

0 Answers0