LINQ使用共享对象

时间:2013-11-28 14:19:18

标签: c# linq linq-to-sql mapping

我有一个表(称为!test),其中包含以下数据:

id  code    desc
0   55      fifty-five
1   66      sixty-six 
2   100     hundred

当我使用以下代码访问该表时,它会编译&运行好, 但不会填充Tuple结构。

[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.!test")]
public partial class Test
{
    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

    private int _ID;
    private TupleClass _Tuple;

    public Test()
    {
        _Tuple = new TupleClass();
    }

    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ID", DbType="Int NOT NULL", IsPrimaryKey=true)]
    public int ID
    {
        get
        {
            return this._ID;
        }
        set
        {
            if ((this._ID != value))
            {
                this._ID = value;
            }
        }
    }

    public TupleClass Tuple
    {
        get
        {
            return this._Tuple;
        }
        set
        {
            if ((this._Tuple.Code != value.Code))
            {
                this._Tuple.Code = value.Code;
            }

            if ((this._Tuple.Desc != value.Desc))
            {
                this._Tuple.Desc = value.Desc;
            }
        }
    }
}

public class TupleClass
{
    private int _Code;

    private string _Desc;

    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Code", DbType = "Int NOT NULL")]
    public int Code
    {
        get
        {
            return this._Code;
        }
        set
        {
            if ((this._Code != value))
            {
                this._Code = value;
            }
        }
    }

    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Desc", DbType = "NVarChar(50)")]
    public string Desc
    {
        get
        {
            return this._Desc;
        }
        set
        {
            if ((this._Desc != value))
            {
                this._Desc = value;
            }
        }
    }
}

我在这里做错了什么想法?感谢

0 个答案:

没有答案