0
我有以下LINQ查詢從我的數據庫返回兩個對象。這些對象將由ViewModel
是強類型的顯示模板消耗:使用MVC2向構造函數添加多個參數
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)
{
}
}
我得到的語法錯誤,指出不能在使用一個以上的類型,使用或固定的聲明。
我在做什麼錯?
謝謝你們的快速反應,學校的男孩錯誤。 – Liam
謝謝,我需要爲這個方法中的對象添加單獨的屬性嗎?即時通訊思維不像他們在我的實體,最終我想創建一個列表包含兩個對象的屬性? – Liam
@Liam,你不應該在構造函數中添加屬性。屬性被添加到類中。 –