lundi 13 juin 2022

How to get all properties of fields in my tables from entry of dbcontext ef in c#?

this is my code:

foreach (PropertyInfo prop in typeof(myDbContext).GetProperties())
{
     if (!prop.PropertyType.Name.StartsWith("DbSet"))
     {
          continue;
     }
     var myCls = prop.PropertyType.GenericTypeArguments[0];
     var entry = _axsc05Context.Model.FindEntityType(myCls);
     var primaryKeies = entry?.FindPrimaryKey();
     var foregnKeys = entry?.GetForeignKeys();
     var myClsProperties = myCls.GetProperties();
     foreach (var p in myClsProperties)
     {
         string propertyComment=?//entity.Property(e => e.TypeMilitaryOrgan).HasComment("[myComment]");
         string propertyColumnName=?//.HasColumnName("myColumnName")
         string propertyColumnType=?//.HasColumnType("money")
         bool isGenerateNever=?//.ValueGeneratedNever()
     }
}

how can i find the values that i set in dbcontext:

string propertyComment=?//entity.Property(e => e.TypeMilitaryOrgan).HasComment("[myComment]");
string propertyColumnName=?//.HasColumnName("myColumnName")
string propertyColumnType=?//.HasColumnType("money")
bool isGenerateNever=?//.ValueGeneratedNever()

i want to get all properties of fields in my tables





Aucun commentaire:

Enregistrer un commentaire