lundi 17 avril 2023

Reflection POCO class and auto CreateInstance via .net6

The front-end only needs to pass in the entity name to achieve database queries,there is my code:

var entityType = Assembly.Load("system.domain").GetTypes().Where(a => a.Name == "AccountType").FirstOrDefault();
var repositoryType = typeof(infra.IRepository<>).MakeGenericType(entityType);
//????: CS0118 error,how to fix the error.
var r = ServiceLocator.Current.GetInstance<infrastructure.IRepository<????>>();

thanks!





Aucun commentaire:

Enregistrer un commentaire