日期:2014-05-20  浏览次数:20655 次

谁帮忙看下这段代码,《Linq高级编程》中的实例无法调试通过
C# code


public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }

    public class AdventureWorks : DataContext
    {
        public AdventureWorks(string connection)
            : base(connection)
        {
        }

        public IEnumerable<OrderBySalesPersonID> SalesOrders([Parameter(DbType="int")] int salesPersonID)
        {

            /*这里出现提示:
错误    3    非泛型 方法“System.Data.Linq.DataContext.ExecuteMethodCall(object, System.Reflection.MethodInfo, params object[])”不能与类型实参一起使用    D:\Source\AppTest\Test4\Form1.cs    39    25    Test4
*/
            return this.ExecuteMethodCall<OrderBySalesPersonID> (this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), salesPersonID);
        }
    }

    [Table(Name="SalesPersonOrders")]
    public partial class OrderBySalesPersonID
    {
        private int _productID;
        private string _productName;
        private int _salesPersonID;
        private string _firstName;
        private string _middleName;
        private string _lastName;
        private decimal _unitPrice;

        [Column(Name="ProductID",Storage="_productID",DbType="int")]
        public int ProductID
        {
            get
            {
                return this._productID;
            }
            set
            {
                if((this._productID != value))
                {
                    this._productID = value;
                }
            }
        }

        [Column(Name="Name",Storage="_productName",DbType="nvarchar(50)")]
        public string ProductName
        {
            get
            {
                return _productName;
            }
            set
            {
                if((this._productName != value))
                {
                    this._productName = value;
                }
            }
        }

        [Column(Name="SalesPersonID",Storage="_salesPersonID",DbType="int")]
        public int SalesPerson
        {
            get
            {
                return this._salesPersonID;
            }
            set
            {
                if((this._salesPersonID != value))
                {
                    this._salesPersonID = value;
                }
            }
        }


        [Column(Name="FirstName",Storage="_firstName",DbType="nvarchar(50)")]
        public string FirstName
        {
            get
            {
                return _firstName;
            }
            set
            {
                if ((this._firstName != value))
                {
                    this._firstName = value;
                }
            }
        }

        [Column(Name="MiddleName",Storage="_middleName",DbType="nvarchar(50)")]
        public string MiddleName
        {
            get
            {
                return _middleName;
            }
            set
            {
                if ((this._middleName != value))
                {
                    this._middleName = value;
                }
            }
        }

        [Column(Name="LastName",Storage="_lastName",DbType="nvarchar(50)")]
        public string LastName
        {
            get
            {
                return _lastName;
            }
            set
            {
                if ((this._lastName != value))
                {
                    this._lastName = value;
                }
            }
        }


        [Column(Name="UnitPrice",Storage="_unitPrice",DbType="decimal")]
        public decimal UnitPrice
        {
            get
            {
                return _unitPrice;
            }
            set
            {
                if ((_unitPrice != value))
                {
                    _unitPrice = value;
                }
            }
        }
    }