LINQ でロープを学習して DB を作成し、テーブル レコードを更新しようとしましたが、メンバー P.roject1.ChildDBdetails.Id を取得し続け、SQL への変換がサポートされていません。これはクエリです:
public void UpdateChildrecord()
{
using (ChildDBDataContext ChildDB = new ChildDBDataContext(Con_String))
{
IQueryable<ChildDBdetails> query =
from c in ChildDB.ChildDBdetails
where c.Id == id
select c;
ChildDBdetails updaterecord = query.FirstOrDefault();
updaterecord.Team = newteam;
ChildDB.SubmitChanges();
}
}
私はlinq-to_sqlの初心者で、なぜこれが起こっているのかよくわかりません.どうすればエラーを修正できますか? ありがとう。
テーブルモデル:
[Table]
public class ChildDBdetails : INotifyPropertyChanged, INotifyPropertyChanging
{
[Column(IsPrimaryKey = true, IsDbGenerated = false, CanBeNull = false)]
private int id;
public int Id
{
get { return id; }
set
{
NotifyPropertyChanging("Id");
id = value;
NotifyPropertyChanged("Id");
}
}
[Column]
private string team;
public string Team
{
get { return team; }
set
{
NotifyPropertyChanging("Team");
team = value;
NotifyPropertyChanged("Team");
}
}
#region Implementation of INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
#region Implementation of INotifyPropertyChanging
public event PropertyChangingEventHandler PropertyChanging;
private void NotifyPropertyChanging(string propertyName)
{
if (PropertyChanging != null)
{
PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
}
}
#endregion
}