【问题标题】:Subsonic 3.0.0.5 Migration Row UpdateSubsonic 3.0.0.5 迁移行更新
【发布时间】:2009-08-01 19:13:50
【问题描述】:

我想更新一个表格行并且我有以下代码

无效 updatePrimaryPaymentAndSecondaryPaymentSourceTypes()

{

LookUpDetails lookUpDetail = new LookUpDetails();

var repo = new SimpleRepository("E2Lending", SimpleRepositoryOptions.RunMigrations);

lookUpDetail = repo.Single(80);

lookUpDetail.Col1Value = "我的支票账户";

repo.Update(lookUpDetail);

}

公共类 LookUpDetails

{

[SubSonicPrimaryKey]

public int LookUpDetailId {get; set;}

public int LookUpGroupId { get; set; }

public string Code { get; set; }

public int SortOrder { get; set; }

public string Col1Value { get; set; }

[SubSonicNullString]

public string Col2Value { get; set; }

[SubSonicNullString]

public string Col3Value { get; set; }

[SubSonicNullString]

public string Col4Value { get; set; }

[SubSonicNullString]
public string Col5Value { get; set; }

public DateTime  CreatedOn { get; set; }

public string CreatedBy { get; set; }

public DateTime ModifiedOn { get; set; }

public string ModifiedBy { get; set; }

public Boolean IsActive { get; set; }

}

当我执行然后 repo.Update(lookUpDetail);显示空引用异常。 你能告诉我如何更新表中的单个记录吗?

问候

【问题讨论】:

    标签: sql-server subsonic subsonic3


    【解决方案1】:

    我对非常​​简单的模型类也有同样的问题:

    class Person
    {
        public long ID {get;set;} 
        public string Name { get; set;}
    }
    
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Edit(int id, FormCollection collection) {
        Person toUpdate = Repository.All<Person>().Single(p => p.ID == id);
        TryUpdateModel(toUpdate, collection.ToValueProvider());
        Repository.Update(toUpdate); //throws nullreferenceexception
        return RedirectToAction("Index");
    }
    

    堆栈跟踪:

    在 SubSonic.Query.Update.GetCommand()

    在 SubSonic.Query.Update.Execute()

    在 SubSonic.Repository.SimpleRepository.Update[T](T 项)

    在 MvcApplication1.Controllers.PersonController.Edit(Int32 id, FormCollection 集合)

    在 H:\...\Controllers\PersonController.cs:line 71"

    我的配置:SubSonic 3、SQLite、空数据库

    【讨论】:

      【解决方案2】:

      我也遇到了这个问题,我能够下载最新的 SubSonic 源并且问题已经得到解决。只需打开 SubSonic.Core 项目并构建并替换您的项目对 SubSonic.Core 的引用。

      下载最新源代码 http://github.com/subsonic/SubSonic-3.0

      繁荣 - 存储库更新再次起作用!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-26
        • 2017-02-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多