Я использую «Object Relational Designer» для создания сущностей для моих таблиц базы данных SQL.
Вопрос: почему некоторые классы реализуют INotifyPropertyChanging
, INotifyPropertyChanged
, а другие нет?
Проблема возникла, когда я захотел обновить некоторые данные в моей базе данных с помощью сущности LINQ To SQL, которая не реализует INotifyPropertyChanging
, INotifyPropertyChanged
.
определение сущности:
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.user_to_user")]
public partial class user_to_user
{
private int _user_id1;
private int _user_id2;
private string _relation_type;
public user_to_user()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_user_id1", DbType="Int NOT NULL")]
public int user_id1
{
get
{
return this._user_id1;
}
set
{
if ((this._user_id1 != value))
{
this._user_id1 = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_user_id2", DbType="Int NOT NULL")]
public int user_id2
{
get
{
return this._user_id2;
}
set
{
if ((this._user_id2 != value))
{
this._user_id2 = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_relation_type", DbType="VarChar(50) NOT NULL", CanBeNull=false)]
public string relation_type
{
get
{
return this._relation_type;
}
set
{
if ((this._relation_type != value))
{
this._relation_type = value;
}
}
}
}
DataContext:
private Table<user_to_user> friendsTable = new BSocialDBDataContext().GetTable<user_to_user>();
тогда я пытаюсь:
public void FriendshipOffer(int visitor_id, int owner_id)
{
var relation = friendsTable.FirstOrDefault(u => (u.user_id2 == visitor_id && u.user_id1 == owner_id));
relation.relation_type = "friend";
friendsTable.Context.SubmitChanges();
}