0

Alright so I have a user table that I would like to check against. This user table has a username, email, and accountnumber. Would I would like to do is check if anyone of those has been taken and if it has return if it has been taken.

I was thinking about doing an array example

CHECK AGAINST TABLE 
IF USERNAME MATCHES INSERT @ARRAY "TRUE"
IF EMAIL MATCHES INSERT @ARRAY "TRUE"
ETC.

Then on the C# side I will call the array and check by index

If registrationValidationArray[0] = "true"
{
   ViewBag.UserNameTaken = "True"
   return view("Registration")
   // On cshtml post error next to username that it has been taken
}

So my question is does this approach sound logical and sound like it will work or is there another approach that might help me here procedure wise. Another developer suggested an incremental for the procedure so if username is taken +1 and then on the C# side display according to the numeric value but I couldn't wrap my head around that one. Anyone know of a better way or see a flaw in my logic?

4

1 回答 1

1

如果您使用的是Telerik OpenAccess ORM,并且您有一个存储过程从检查中返回详细信息,我建议您将此存储过程映射到Domain Method,那么 OpenAccess 将返回一个具有良好命名属性的对象。您可以使用返回的对象而不是数组。这将使您的代码更具可读性和更易于维护。现在你应该记住索引 0 和索引 1 的含义,即使你将索引定义为常量,它也不会是一个引人注目的代码。

于 2013-11-22T09:56:53.150 回答