Linq to sql 为什么LINQ到SQL代理类有时实现INotifyPropertyChanged和INotifyPropertyChanged
我正在使用“对象关系设计器”为我的SQL数据库表创建实体 问题:为什么有些类实现了Linq to sql 为什么LINQ到SQL代理类有时实现INotifyPropertyChanged和INotifyPropertyChanged,linq-to-sql,Linq To Sql,我正在使用“对象关系设计器”为我的SQL数据库表创建实体 问题:为什么有些类实现了INotifyPropertyChanging,INotifyPropertyChanged,而其他类没有 当我想使用LINQ to SQL实体更新数据库中的某些数据时,出现了一个问题,该实体未实现inotifPropertyChanged,inotifPropertyChanged 实体辩护: [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.
INotifyPropertyChanging
,INotifyPropertyChanged
,而其他类没有
当我想使用LINQ to SQL实体更新数据库中的某些数据时,出现了一个问题,该实体未实现inotifPropertyChanged
,inotifPropertyChanged
实体辩护:
[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;
}
}
}
}
数据上下文:
private Table<user_to_user> friendsTable = new BSocialDBDataContext().GetTable<user_to_user>();
实体键是否包含在linq语句的返回数据中?实体键是否包含在linq语句的返回数据中?user\u to\u user,是一个COCTION表,它不能有主键。我是否可以使用LINQ to SQL生成udate,而不在user_to_user表中包含主键?user_to_user是一个COCTION表,它不能有主键。我可以使用LINQ to SQL生成udate,而不在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();
}