使用 MVC2 向构造函数添加多个参数
我有以下 LINQ 查询,它从数据库返回两个对象。这些对象将由强类型化为显示模板的 ViewModel
使用:
public IQueryable<ICustomerSiteRepository> CustomerAndSites
{
get
{
return from customer in customerTable
join site in customerSitesTable
on customer.Id equals site.CustomerId
select new CustomersAndSitesMix(customer, site);
}
}
我正在尝试创建一个新的 CustomersAndSitesMix
类,其构造函数接受两个参数(客户和网站)。
但是,当我创建类并尝试像这样设置构造函数时:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CustomerDatabase.Domain.Entities
{
public class CustomersAndSitesMix (CustomerSite custSite, Customer cust)
{
}
}
我收到语法错误,指出不能在 for、using 或fixed 声明中使用多种类型。
我做错了什么?
I have the following LINQ query that returns two objects from my database. These objects will be consumed by a ViewModel
that is strongly typed to a display template:
public IQueryable<ICustomerSiteRepository> CustomerAndSites
{
get
{
return from customer in customerTable
join site in customerSitesTable
on customer.Id equals site.CustomerId
select new CustomersAndSitesMix(customer, site);
}
}
I am trying to create a new CustomersAndSitesMix
class with a constructor that accepts two parameters (the customer and the site).
However, when I create the class and try to set up the constructor like so:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CustomerDatabase.Domain.Entities
{
public class CustomersAndSitesMix (CustomerSite custSite, Customer cust)
{
}
}
I get syntax errors stating that cannot use more than one type in a for, using or fixed declaration.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该首先声明该类:
You should declare the class first:
在类内部实现构造函数。不在命名空间内
Implement constructor inside class. Not inside namespace