Using Linq2Db with SQLServer Table with unknown extra columns #4248
Unanswered
Fungusware
asked this question in
Q&A
Replies: 1 comment
-
It is not clear to me how you want to use it, so there are some options Option 1: custom configuration per-customer
var db = new DataConntection(new DataOptions()/*...*/.UseConfigurationString("SomeCustomer"));
class Table
{
[NotColumn] // without configuration - default mapping
[Column("name", Configuration = "SomeCustomer")] // applied only to specific configuration
[Column("name_long", Configuration = "SomeOtherCustomer")] // applied only to specific configuration
public string Name { get; set; }
} Cons:
Option 2: use Sql.Property dynamic mappingsSome examples could be found in tests here, here and here Options 3: just define per-customer table mappings[Table("CustomFields")] class Customer1Fields { /*...*/ }
[Table("CustomFields")] class Customer2Fields { /*...*/ }
[Table("CustomFields")] class Customer3Fields { /*...*/ } |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have a situation where (for good or bad) we deploy a standard set of database Tables for every customer. There is also another set of Tables that can have multiple extra columns in them.
Example :
Customer
ID
,Name
,Address
CustomerCustomValues
ID
,CustomerID
,WorkLocation
,LastContacted
The
CustomerCustomValues
table varies per customer.Is there a way we can use Linq2DB to work with these CustomValues columns. Either with Runtime compilation or Custom Schema Mapping at runtime. I've tried both but so far can't get it to work.
Obviously I'm happy to refer to the custom columns by name, since they wont be known upfront.
Thanks in advance, open to any ideas.
Beta Was this translation helpful? Give feedback.
All reactions