[英]C# object unique
在我的asp.net Web应用程序中,我正在使用对象将信息添加到数据库中,如下所示
Employee emp1 = new Employee()
emp1.name = "something"
emp1.age = some age
InsertEmployee(emp)
此代码可以正常工作。 但是,如果有多个用户试图插入员工数据,则数据会变得混乱。
然后,用户打电话说:“我输入的年龄与为员工XXX显示的年龄不同。
如何解决呢? 什么是使对象唯一的好方法?
谢谢....
您可以使用Guid类型使对象唯一。 emp1.Guid = Guid.NewGuid();
User then calls up and says , "The age I entered is different from what it is showing for employee XXX.
您如何更新用户结果?
How to fix this ? Whats the good method to make the object unique ?.
您需要在数据库中添加主键。 然后针对该主键执行所有数据库操作。 您可以在此处阅读有关SQL密钥的信息 。
update yourTable
SET
YourColumnName = YourValue
Where
tableId = Idofthisemployee
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.