I have a SQL Database that I am going to be interacting with via LINQ once built. It has a client who has (ignoring the others) two fkID fields to two tables.
Class
Country
What I am trying to do is store a "Rules" table where the following happens:
if the Class is 'A' and the Country is 'USA' then
create rows 'RowsA' in table todo
else if the class is 'A' and the country is not 'USA' then
create rows 'RowsB' in table todo
else
create rows 'RowsC' in table todo
So, is the best way to do this to have in the rules table
RuleID Identity
ClassFK Int null
CountryFK Int null
order int not null
and have my C# code do the following:
var rules = from r in db.Rules
orderby r.order
select r;
foreach(rule in rules)
{
if (((client.ClassFK == rule.ClassFK) || (rule.ClassFK == null)) &&
((client.CountryFK== rule.CountryFK) || (rule.CountryFK== null)))
{
// Create The Rows
}
}
This seems awfully flimsy to me