返回单个实例对象
- /// <summary>
- /// 按指定的名字返回城市对象
- /// </summary>
- /// <param name="cityName"></param>
- /// <returns></returns>
- [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
- public static City SelectByName(string cityName)
- {
- DataProviders.IDataProvider provider = CreateDataProvider();
- provider.SQL = "SELECT CityID as [Identity],Name,PostalCode,DistanceCode,Province,Longitude,Latitude,Version " +
- "FROM lt_dictionary.City WHERE Name=@name";
- provider.AddParameters("@name", cityName);
- return CreateInstance(provider.ExecuteDataTable());
- }
返回集合对象
- /// <summary>
- /// 返回所有禁用状态的城市信息
- /// </summary>
- /// <returns></returns>
- [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
- public static List<City> SelectIsDisabled()
- {
- DataProviders.IDataProvider provider = CreateDataProvider();
- provider.SQL = "SELECT CityID as [Identity],Name,PostalCode,DistanceCode,Province,Longitude,Latitude,Version " +
- "FROM lt_dictionary.City WHERE Enable=0";
- //返回List<City>
- return CreateInstances(provider.ExecuteDataTable());
- }
本文转自shyleoking 51CTO博客,原文链接:http://blog.51cto.com/shyleoking/805778