mardi 4 avril 2017

check if context has some table then add to this table

i have multiple DbContexts and each context has some DbSets like

public class fooContext : DbContext 
{
    DbSet<fooA> fooA {get,set}
    DbSet<fooB> fooB {get,set}
}

public class barContext : DbContext 
{
    DbSet<barA> barA {get,set}
    DbSet<barB> barB {get,set}
}

and an excel file with multiple excelSheets structered properly for linqtosql to work with (having sheet names as fooA,fooB... ,first row is properties names and remaining rows are data)

i can see that if i have which context has fooA i can use something like this function inside the context

public DbSet Set(string "fooA")
{
  return base.Set(Type.GetType("fooA"));
}

but i don't which context has fooA to add this to

to clarify this ,, normally when you want to add fooARecord to fooA table in fooContext you

fooContext.fooA.Add(fooARecord);

but i only have fooA as string and fooARecord

P.S: cant use linqtosql since oracle and i cant simply import excel to oracle coz too many tables and users need to be able to alter this data before this process





Aucun commentaire:

Enregistrer un commentaire