choose table in run time with linq to sql RRS feed

  • Question

  • Hello

    Suppose I have 5 clients which have the same type of data, for example - they all have [int-id, string-employer, real-salary]

    I think it's better to save each client in a different table in the database. even though the data is the same - my queries will be simpler if each client have his own table, and I don't most check all the time if this row belong to this particular client.

    But in this case - how i search with linq in the database? am I obligated to build 5 classes - a class for each client, or I can build one class which match to all clients.

    I tried to build one class, and it's not working because in the attribute (Table) I most specify the name of the table in the database, so this class can belong to only one table. 

    And i'm wondering if there is any solution to change in a way that I can take the class for all the tables.


    • Moved by Kristin Xie Thursday, September 24, 2015 8:32 AM move to better forum
    Wednesday, September 23, 2015 8:38 PM


  • Why not build an additional table called Clients and have it as [ClientID, Name] then add the ClientID as a foreign key in your original table? In my opinion that makes much more sense vs creating a separate table for each client.


    Wednesday, September 23, 2015 8:41 PM

All replies