我有班的国家有城市集合。我有很好的静态法的感觉
在客户端我用的WebMethod
[WebMethod]
public void AddCity(string countryCode,string name)
{
MyFacade.AddCity(countryCode,name);
}
在门面我有方法
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()
我认为无论是'MyFacade.AddCity'和'Country.AddCity'是静态的。 – 2010-10-14 16:57:41
是的,Facade是一个静态类,MyFacade.both MyFacade.AddCity和Country.AddCity是静态的。 – user278618 2010-10-14 17:02:13
这就是我不同意的。这不是'Country'类型需要有状态和多态,而是数据库连接。 – 2010-10-14 17:13:05