Is it possible to ignore missing columns? #4142
-
I have an issue using POCO classes for a third party database where some installations have more columns than others for the same table (different versions). But, I want our code to pickup these values if they exist and ignore any that are missing. Using a GetTable<>() call, the generated SQL creates a SELECT statement with named columns, but this obviously throws an error when connected to a database that is missing one of these columns in the table. To be clear, the POCO class will have all of the potential column names as class properties, but the database may or may not have all of the columns in the table. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There is no exitense check for column. public class MyTable
{
// available by default to all configurations
[Column]
public int Column1 { get; set; }
// available only to config1 and config2 configurations
[Column(Configuration="config1"), Column(Configuration="config2")]
public int Column2 { get; set; }
// available to all configurations except config3
[Column, NotColumn(Configuration="config3")]
public int Column3 { get; set; }
} |
Beta Was this translation helpful? Give feedback.
There is no exitense check for column.
What you can do is define multiple configurations and enable/disable columns per-configuration: