У меня есть таблица TemplateRelations, в которой я хочу установить EntityRef _Template; быть нулевым, но я не уверен, как это сделать. Я пытался сделать что-то вроде этого частного System.Nullable _Template;, но получаю некоторые ошибки
Шаблон типа должен быть типом значения, не допускающим значения NULL, чтобы использовать его в качестве параметра «T» в универсальном типе или методе, допускающем значение NULL.
public TemplateRelation()
{
this._Template = default(EntityRef);
this._Template1 = default(EntityRef);
this._TemplateRelationType = default(EntityRef);
OnCreated();
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.TemplateRelations")]
public partial class TemplateRelation : IDatabaseEntity, INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private long _Id;
private System.DateTime _Added;
private System.Nullable _Modified;
private System.Nullable _Deleted;
private bool _IsDeleted;
private bool _Frozen;
private bool _HasPagebreak;
private string _ReferenceText;
private System.Nullable _TemplateRelationTypeId;
private System.Nullable _RelatedTemplateId;
private long _TemplateId;
private EntityRef _Template;
private EntityRef _Template1;
private EntityRef _TemplateRelationType;
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Template_TemplateRelation1", Storage="_Template1", ThisKey="TemplateId", OtherKey="Id", IsForeignKey=true)]
public System.Nullable Template
{
get
{
return this._Template1.Entity;
}
set
{
Template previousValue = this._Template1.Entity;
if (((previousValue != value)
|| (this._Template1.HasLoadedOrAssignedValue == false)))
{
this.SendPropertyChanging();
if ((previousValue != null))
{
this._Template1.Entity = null;
previousValue.ParentTemplateRelations.Remove(this);
}
this._Template1.Entity = value;
if ((value != null))
{
value.ParentTemplateRelations.Add(this);
this._TemplateId = value.Id;
}
else
{
this._TemplateId = default(long);
}
this.SendPropertyChanged("Template");
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... f-nullable