Clothes.DAL/BaseDAL.cs
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Clothes.IDAL;
using Clothes.Model;
namespace Clothes.DAL
{
public class BaseDAL<T>:BaseIDAL<T> where T:BaseContext
{
//protected ClothesContext context { get; set; } = new ClothesContext();
public ClothesContext context
{
get {
return new ClothesContext();
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public bool Delect(int id)
{
var con = context;
var date = con.Set<T>().SingleOrDefault(a => a.Id ==id);
con.Set<T>().Remove(date);
var aa = con.SaveChanges();
return context.SaveChanges() > 0;
}
/// <summary>
/// 添加
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public bool Insert(params T[] t)
{
var a = context;
a.Set<T>().AddRange(t);
var aaa = a.SaveChanges();
return aaa>0;
}
/// <summary>
/// 查询
/// </summary>
/// <param name="expression"></param>
/// <returns></returns>
public List<T> Select(Expression<Func<T, bool>> expression)
{
var con = context;
return con.Set<T>().Where(a => a.Delect != true).Where(expression).ToList();
}
后面还有 15 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。