我的业务层代码,用查找替换的方式就能很轻松的完成对表的一般性操作.
public class ProductCateCateService
{
public static void Save(ProductCate d)
{
NBearData.DB().Save(d);
}
public static void Del(int id)
{
NBearData.DB().Delete<ProductCate>(id);
}
public static ProductCate GetOne(int id)
{
return NBearData.DB().Find<ProductCate>(id);
}
public static int GetCount()
{
return NBearData.DB().From<ProductCate>().ToArray<ProductCate>().Length;
}
public static ProductCate[] GetAll()
{
return NBearData.DB().From<ProductCate>().ToArray<ProductCate>();
}
public static ProductCate[] GetAll(int pz, int pn)
{
return NBearData.DB().From<ProductCate>().ToArray<ProductCate>(pz, (pn - 1) * pz);
}
public static ProductCate[] GetAll(WhereClip w)
{
return NBearData.DB().From<ProductCate>().Where(w).ToArray<ProductCate>();
}
public static ProductCate[] GetAll(WhereClip w, int pz, int pn)
{
return NBearData.DB().From<ProductCate>().Where(w).ToArray<ProductCate>(pz, (pn - 1) * pz);
}
}
{
public static void Save(ProductCate d)
{
NBearData.DB().Save(d);
}
public static void Del(int id)
{
NBearData.DB().Delete<ProductCate>(id);
}
public static ProductCate GetOne(int id)
{
return NBearData.DB().Find<ProductCate>(id);
}
public static int GetCount()
{
return NBearData.DB().From<ProductCate>().ToArray<ProductCate>().Length;
}
public static ProductCate[] GetAll()
{
return NBearData.DB().From<ProductCate>().ToArray<ProductCate>();
}
public static ProductCate[] GetAll(int pz, int pn)
{
return NBearData.DB().From<ProductCate>().ToArray<ProductCate>(pz, (pn - 1) * pz);
}
public static ProductCate[] GetAll(WhereClip w)
{
return NBearData.DB().From<ProductCate>().Where(w).ToArray<ProductCate>();
}
public static ProductCate[] GetAll(WhereClip w, int pz, int pn)
{
return NBearData.DB().From<ProductCate>().Where(w).ToArray<ProductCate>(pz, (pn - 1) * pz);
}
}