I want to make "Common.Student" and "xyzProp" dynamic(replaced programmatically),
I have them as string right now how to handle Type
var builder = new ODataConventionModelBuilder();
var entity = builder.EntityType
entity.Ignore(x => x.xyzProp);
I want to make "Common.Student" and "xyzProp" dynamic(replaced programmatically),
I have them as string right now how to handle Type
var builder = new ODataConventionModelBuilder();
var entity = builder.EntityType
entity.Ignore(x => x.xyzProp);
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jayraj ChhayaRank #304 · 8.2K reputationPosted Apr 3, 2024, 8:58 AM EDT
To dynamically ignore properties at runtime in .NET EF Core and OData, you can achieve this by using reflection to access the entity type and ignore the specified property.
var builder = new ODataConventionModelBuilder(); var entity = builder.EntityType(); // Get the property information using reflection var propertyInfo = typeof(Common.Student).GetProperty("xyzProp"); // Ignore the property dynamically entity.Ignore(propertyInfo);Ketan KolteRank #5,059 · 313 reputationPosted Apr 4, 2024, 12:32 PM EDT
in your code Common.Student seems to be EntityTpye , but i currently have it as a String "Common.Student" need to convert it to Tpye at runtime.