英文:
Why does my if condition not return the result? Is my if condition wrong?
问题
我想要实现一个if
条件,如果我的Model.Reference
在数据库中已经存在ID,就不生成ID或调用_sysautoController.GUID
。
我希望当Model.Reference
不为空时,不生成ID
或调用_sysautoController.GUID
,而当Model.Reference
为空或空字符串时,才调用_sysautoController.GUID
来生成ID
。
这是我尝试过的代码:
if (Model.Reference != null)
{
}
else if (Model.Reference == null)
{
_sysautoController.GUID(1, Model.TranCompNo);
}
英文:
I want to implement an if
condition to not generate ID or call the _sysautoController.GUID
if my Model.Reference
has an ID that already exists in the database.
I want it to not generate ID
or call _sysautoController.GUID
if Model.Reference
is not null, and if Model.Reference
is null or empty, that's the time it will call _sysautoController.GUID
to generate an ID
.
Here is my code that I have tried
if (Model.Reference != null)
{
}
else if (Model.Reference == null)
{
_sysautoController.GUID(1, Model.TranCompNo);
}
答案1
得分: 1
以下是翻译的内容:
也许你可以尝试这样做
if (Model.Reference != null)
{
}
else
{
_sysautoController.GUID(1, Model.TranCompNo);
}
英文:
Maybe you can try it just like this
if (Model.Reference != null)
{
}
else
{
_sysautoController.GUID(1, Model.TranCompNo);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论