【发布时间】:2026-01-10 00:20:06
【问题描述】:
我的 Country 类包含 Cities 集合。
在客户端我使用 webmethod
[WebMethod]
public void AddCity(string countryCode,string name)
{
MyFacade.AddCity(countryCode,name);
}
在 Facade 我有方法
public void AddCity(string countryCode,string name)
{
Country.AddCity(countryCode,name); <-in this method is simple sql operation
}
我的问题的核心:
public class Country
{
public static void AddCity(string countryCode, string cityName)
{
//insert into table cities new city
}
}
没事吧?或者我必须创建objectCountry,并且有非静态方法AddCity?
还有一个问题:
更好的使用:
City[] cities= Country.GetAllCities(countryCode)
或
City[] cities= new Country(countryCode).GetAllCities()
【问题讨论】: