A bit late to the party, but still there is another way of doing this, it's possible to create a separate LINQ table class per variant "type" that you're storing in the database table. This allows you to perform your insert operations. for example;
[Table(Name = "tVariant")]
public class tVariantDouble
{
[Column(IsPrimaryKey = true, IsDbGenerated = true)]
public int variantID { get; set; }
[Column(CanBeNull = true)]
public double? myVariant { get; set; }
[Column(CanBeNull = true)]
public string name { get; set; }
[Column(CanBeNull = false)]
public int typeID { get; set; }
public tVariantDouble() { typeID = 1; }
};
[Table(Name = "tVariant")]
public class tVariantInteger
{
[Column(IsPrimaryKey = true, IsDbGenerated = true)]
public int variantID { get; set; }
[Column(CanBeNull = true)]
public int? myVariant { get; set; }
[Column(CanBeNull = true)]
public string name { get; set; }
[Column(CanBeNull = false)]
public int typeID { get; set; }
public tVariantInteger() { typeID = 2; }
};
These classes then allow you to insert in the traditional LINQ-to-SQL method. I also set the typeID during the insert to an unique value, which is useful for selecting the data of the appropriate type again, with a LINQ where statement.
I would suggest creating a base template class for the same table, however LINQ is clunky at best with inheritance and it simply won't work.
This method does cause a little bit of duplication, but still quite a neat method of accomplishing this, with less drawbacks than the other suggested methods.
If you wanted to select all the data from the table, regardless of variant type, I would suggest using the union operator with a separate intermediate class to join all the results up.