/// <summary> /// 添加一个实体 /// </summary> /// <param name="entity"></param> /// <param name="primaryKey"></param> /// <returns></returns> public bool Insert(T entity, Expression <Func <T, object> > primaryKey = null) { return(_context.Insert(entity, ExpressionUtils.GetProperty(primaryKey)) > 0 ? true : false); }
/// <summary> /// 根据主键获取一个实体 /// </summary> /// <param name="id"></param> /// <returns></returns> public T Get <TValue>(Expression <Func <T, object> > primaryKey, TValue value) where TValue : struct { return(_context.Get <T, TValue>(ExpressionUtils.GetProperty(primaryKey), value)); }