Giter Site home page Giter Site logo

var t10 = db.Updateable<Student>() .UpdateColumns(it => new Student() { Name = "a", CreateTime = DateTime.Now }) .Where(it => it.Id == 11).ExecuteCommand(); 无法执行 about sqlsugar HOT 7 CLOSED

donet5 avatar donet5 commented on April 28, 2024
var t10 = db.Updateable() .UpdateColumns(it => new Student() { Name = "a", CreateTime = DateTime.Now }) .Where(it => it.Id == 11).ExecuteCommand(); 无法执行

from sqlsugar.

Comments (7)

DotNetNext avatar DotNetNext commented on April 28, 2024

我的源码可以通过

from sqlsugar.

haibozhou1011 avatar haibozhou1011 commented on April 28, 2024

我是封装成 Repository 模式,然后在业务层调用就报错!直接用时没有问题。

from sqlsugar.

haibozhou1011 avatar haibozhou1011 commented on April 28, 2024

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using IrobotBox.Infrastructure.Model;
using IrobotBox.Infrastructure.Repository.Base.IBaseRepository;

namespace IrobotBox.Infrastructure.Repository.Base.BaseRepository
{
public partial class Repository<TModel, TPrimaryKey> : IRepository<TModel, TPrimaryKey>
where TModel : class, IModel, new()
{
public int Update(TModel model)
{
return DbClient.Updateable(model).ExecuteCommand();
}

    public int Update(Expression<Func<TModel, bool>> whereEpression, Expression<Func<TModel, object>> updateColumns)
    {
        
        return DbClient.Updateable<TModel>().UpdateColumns(updateColumns).Where(whereEpression).ExecuteCommand();
    }

    public int Update(IEnumerable<TModel> models)
    {
        return DbClient.Updateable<TModel>(models).ExecuteCommand();
    }

    public async Task<int> UpdateAsync(TModel model)
    {
        return await DbClient.Updateable<TModel>(model).ExecuteCommandAsync();
    }
    public async Task<int> UpdateAsync(Expression<Func<TModel, bool>> whereEpression, Expression<Func<TModel, object>> updateColumns)
    {

        return await DbClient.Updateable<TModel>().UpdateColumns(updateColumns).Where(whereEpression).ExecuteCommandAsync();
    }
    public async Task<int> UpdateAsync(IEnumerable<TModel> models)
    {
        return await DbClient.Updateable<TModel>(models).ExecuteCommandAsync();
    }
}

}

from sqlsugar.

haibozhou1011 avatar haibozhou1011 commented on April 28, 2024

public int Update(Expression<Func<TModel, bool>> whereEpression, Expression<Func<TModel, object>> updateColumns)
{

        return DbClient.Updateable<TModel>().UpdateColumns(updateColumns).Where(whereEpression).ExecuteCommand();
    }

调用这个方法就报错!

from sqlsugar.

haibozhou1011 avatar haibozhou1011 commented on April 28, 2024

public void Update(long id)
{
_sysUserRepository.Update(m => m.Id == id, m => new Sys_User { UserName = "abcdef" });
}
业务层,是这样调的。

from sqlsugar.

haibozhou1011 avatar haibozhou1011 commented on April 28, 2024

qq 20171211201643

from sqlsugar.

haibozhou1011 avatar haibozhou1011 commented on April 28, 2024

报错是上图所示!

from sqlsugar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.