表:UserTypes
字段:row,name,Type
此代码无效:
Int64 row = 1;
var myType = (from b in dc.UserTypes where b.Row == user.Row select b).Single();
myType.Type = "personalPage";
dc.SubmitChanges();
但是,这段代码确实...
dc.ExecuteQuery<UserType >("update dbo.UserType set Type='personalPage' where row={0}",user.Row
);
我收到这个错误:
Type the word is a word reserved.i can not user word
Type
编辑
数据库管理
[Table(Name="dbo.UserType")]
public partial class UserType
{
private long _Row;
private string _Type;
public UserType()
{
}
[Column(Storage="_Row", DbType="BigInt NOT NULL")]
public long Row
{
get
{
return this._Row;
}
set
{
if ((this._Row != value))
{
this._Row = value;
}
}
}
[Column(Storage="_Type", DbType="NVarChar(500) NOT NULL", CanBeNull=false)]
public string Type
{
get
{
return this._Type;
}
set
{
if ((this._Type != value))
{
this._Type = value;
}
}
}
}
最佳答案
进入您的 LINQ to SQL DBML 映射并将 UserType.Type
的映射从名为“Type”的列更改为名为“[Type]”的列。您可以在设计器中或手动执行此操作。
关于c# - 如何引用 LINQ 中使用保留字命名的字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7153460/