本文介绍了如何基于主键更新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Lightswitch中,为了进行屏幕验证,我可以为特定属性添加validate()方法.它的工作成功地避免了重复.但是对于同一记录,如果我尝试更新,则会引发相同的错误描述.

In Lightswitch, for the screen validation, I was able add validate() method for a particular property. Its works successfully avoiding duplicate. But for the same record if i try to update, it throws same error description.


局部无效BATCH_CODE_Validate(EntityValidationResultsBuilder结果)
        {
            var bCode = this.BATCH.Where(c => c.BATCH_CODE == this.BATCH_CODE).FirstOrDefault();
           如果(bCode!= null)
                results.AddEntityError(重复批处理代码");

partial void BATCH_CODE_Validate(EntityValidationResultsBuilder results)
        {
            var bCode = this.BATCH.Where(c => c.BATCH_CODE == this.BATCH_CODE ).FirstOrDefault();
            if (bCode != null)
                results.AddEntityError("Duplicate Batch Code");

}

Batch_Code(PK)     批处理说明    Active_Indicator

Batch_Code(PK)       Batch_Description      Active_Indicator

第1批                     第1批                              Y

Batch1                      Batch1                              Y

我需要在Lightswitch中执行以下典型的SQL查询

I need to perform the following typical SQL Query in Lightswitch

Update batch_description ="Batch123"来自Batch的代码,其中Batch_Code ="Batch1".

Update batch_description="Batch123" from Batch where Batch_Code = "Batch1".

需要更新"Batch1"的Batch_Description.到"Batch123".  在数据网格中尝试时,它将引发错误消息.如何更新此记录.

Need to update the Batch_Description of "Batch1" to "Batch123".  When tried in the data grid, it throws the error message. How to update this record.


此致

维杰.

推荐答案

这是内部数据库还是附加数据库?

Is this Intrinsic or attached database?

使用DataWorkspace,我认为这将解决您的问题

Use DataWorkspace, I think this one will solve your issue

致谢


这篇关于如何基于主键更新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 07:06