如何引用LINQ中使用保留字命名的字段?

ash*_*raz 5 c# linq sql-server asp.net linq-to-sql

表: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();
Run Code Online (Sandbox Code Playgroud)

但是,这段代码确实......
dc.ExecuteQuery<UserType >("update dbo.UserType set Type='personalPage' where row={0}",user.Row);

我收到此错误:

键入单词是一个单词reserved.i不能用户单词Type

编辑

DBML

  [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;
        }
    }
    }

}               
Run Code Online (Sandbox Code Playgroud)

jas*_*son 7

进入LINQ to SQL DBML映射并将映射UserType.Type从名为"Type"的列更改为名为"[Type]"的列.您可以在设计器中手动执行此操作.