简体   繁体   中英

Bind one class to multiple tables Based on Parameter EF6

I have an old application build using asp.net web forms I'm trying to use the existing database with new application using API2 the problem was application creates new tables for each client registered on the system

ex: 16_Notifications, 17_Notifications,18-....

How to bind Notification Class shown below to one table based on the logged in user

assume have the Id from WebApi as parameter let's say

string Id = 16;

Can I do something like below ?

Table[Id+"_Notifications"]
public class Notification{
public int Id {get;set;}
public string Notification {get;set;}
}

where 16,17 from the logged in user

After Viewing post here Implement IDbModelCacheKey

hope this help someone else for me finally make it's work by changing this line

base(ConfigurationManager.ConnectionStrings["RepositoryConnectionString"] + "; Extended Properties=\\"setElementsTableId=" + setElementsTableId + "\\"")

to using Application Name instead of Extended Properties

base(ConfigurationManager.ConnectionStrings["RepositoryConnectionString"] + " ; Application Name ='setElementsTableId=" + setElementsTableId + "\\'")

in the mentioned post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM