Linq to sql DataContext中具有类型化表的LINQ到SQL继承映射

Linq to sql DataContext中具有类型化表的LINQ到SQL继承映射,linq-to-sql,Linq To Sql,嘿,伙计们,我有一个使用类型化表的LINQ2SQL系统,但现在我尝试在2个类之间添加继承映射,我在创建DataContext实例时遇到了一个错误。错误为“输入字符串格式不正确”。我猜在我的Datacontext类中有类型化的表和我所放置的映射会有一些冲突 这是我的代码的缩写版本 public class DataAccessHelper : DataContext { public static DataContext db; public Table<CronJob>

嘿,伙计们,我有一个使用类型化表的LINQ2SQL系统,但现在我尝试在2个类之间添加继承映射,我在创建DataContext实例时遇到了一个错误。错误为“输入字符串格式不正确”。我猜在我的Datacontext类中有类型化的表和我所放置的映射会有一些冲突

这是我的代码的缩写版本

public class DataAccessHelper : DataContext
{
    public static DataContext db;
    public Table<CronJob> CronJob;
    public Table<SongCronJob> SongCronJob;

    public DataAccessHelper(string connection) : base(connection) { }

}

[Table(Name = "cron_jobs", )]
[InheritanceMapping(Code = "CJ", Type = typeof(CronJob))]
[InheritanceMapping(Code = "SCJ", Type = typeof(SongCronJob))]
public class CronJob //Instantiated by any cron job run
{
    //IsDiscriminator = true, 
    [Column(IsPrimaryKey = true, IsDiscriminator = true, Name = "id", IsDbGenerated = true, CanBeNull = false)]
    public int ID { get; set; }
}

[Table(Name = "cron_jobs_songs")]
public class SongCronJob : CronJob
{
}
堆栈跟踪:

FormatException: Input string was not in a correct format.
System.Number.stringtonNumber(字符串str,numberstyle选项,NumberBuffer&Number,NumberFormatInfo信息,布尔parseDecimal)+9594283 System.Number.ParseInt32(字符串s、NumberStyles样式、NumberFormatInfo信息)+119 System.String.System.IConvertible.ToInt32(IFormatProvider)+46 System.Convert.ChangeType(对象值、类型转换类型、IFormatProvider提供程序)+385 System.Data.Linq.DBConvert.ChangeType(对象值,类型)+3236 System.Data.Linq.Mapping.AttributedRootType..ctor(AttributedMetaModel模型,AttributedMetaTable表,类型类型)+408 System.Data.Linq.Mapping.AttributedMetaTable..ctor(AttributedMetaModel模型,TableAttribute属性属性,类型rowType)+97 System.Data.Linq.Mapping.AttributedMetaModel.GetTableNoLocks(类型rowType)+216 System.Data.Linq.Mapping.AttributedMetaModel.GetTable(类型rowType)+184 System.Data.Linq.DataContext.GetTable(类型)+51 System.Data.Linq.DataContext.InitTables(对象模式)+180 System.Data.Linq.DataContext.Init(对象连接,映射源映射)+269 System.Data.Linq.DataContext..ctor(字符串文件或服务器连接)+44 C:\Users\william\Desktop\Stuff\Important Notables\Subversion Dev\Projects\CodenameDiddy\Helper\Data\DataHelper.cs:20中的Helper.Data.DataAccessHelper..ctor(字符串连接) C:\Users\william\Desktop\Stuff\Important Notables\Subversion Dev\Projects\CodenameDiddy\http\masterpages\Cronxxx.master.cs:32 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,对象o,对象t,事件参数e)+14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发送方,EventArgs e)+35 System.Web.UI.Control.OnLoad(EventArgs e)+91 System.Web.UI.Control.LoadRecursive()+74 System.Web.UI.Control.LoadRecursive()+146
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+2207

我认为这是因为继承映射代码和鉴别器列ID之间的类型不匹配,一个是字符串,另一个是int

FormatException: Input string was not in a correct format.