2.8使用EntityBase
返回单个实例对象 |
/// <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()); } |