安忍不动如大地,静虑深思如秘藏
雄鹰虽然有时候飞的比鸡还低 但鸡永远也不可能飞到鹰的高度

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());

}

 

 

posted on 2008-11-19 14:35  害羞的狮子王  阅读(1042)  评论(0编辑  收藏  举报