views:

37

answers:

0

Title: multiple class with same variable name list has issues in table definition (all indices not null)

lets say i have two class implementing from one interface

public interface IInterface1
{
   IList<string> myList {get; set;}
}

public class class1 : IInterface1
{
    IList <string> myList {get; set;}
    public class1()
    {
       myList = new List<string>();
    }
}

public class class2 : IInterface1
{
    IList<string> myList {get; set;}
    public class2()
    {
       myList = new List<string>();
    }
}

when the table is created the for myList the table definition would be like

  1. class1_id 'not null = true'
  2. value
  3. class2_id 'not null = true'

when you try to save a value it will fail since it will always have only one id value at a time.

when class1 is saved only only class1_id can be saved and class2_id will be empty this would cause the insert to fail with error

'could not insert collection:.....VALUES (?p0, ?p1)]'