public int Queue()
{
using (Entities server = new Entities())
{
var ServerId1 = (from serverID in server.AppPM_Patches
where serverID.PatchStatus == "NotStarted" && serverID.ServerId == 1
select serverID.ServerId).Count();
var ServerId2 = (from serverID in server.AppPM_Patches
where serverID.PatchStatus == "NotStarted" && serverID.ServerId == 2
select serverID.ServerId).Count();
var ServerId3 = (from serverID in server.AppPM_Patches
where serverID.PatchStatus == "NotStarted" && serverID.ServerId == 3
select serverID.ServerId).Count();
if (ServerId1 == 0 && ServerId2 == 0 && ServerId3 == 0)
{
return ServerId1;//Convert.ToInt32(ServerId1);
}
else if (ServerId1 == 1 && ServerId2 == 0 && ServerId3 == 0)
{
return ServerId2;
}
else if (ServerId1 == 1 && ServerId2 == 1 && ServerId3 == 0)
{
return ServerId3;
}
else if (ServerId1 > ServerId2 && ServerId1 > ServerId3)
{
if (ServerId2 > ServerId3)
{
return ServerId3;
}
else
{
return ServerId2;
}
}
else if (ServerId2 > ServerId3 && ServerId2 > ServerId1)
{
if (ServerId1 > ServerId3)
{
return ServerId3;
}
else
{
return ServerId1;
}
}
else if (ServerId3 > ServerId1 && ServerId3 > ServerId2)
{
if (ServerId1 > ServerId2)
{
return ServerId2;
}
else
{
return ServerId1;
}
}
else if (ServerId1 == ServerId2 && ServerId2 == ServerId3 && ServerId1 == ServerId3)
{
return ServerId1;
}
else if (ServerId1 == ServerId2 && ServerId1 > ServerId3 && ServerId2 > ServerId3)
{
return ServerId3;
}
else if (ServerId2 == ServerId3 && ServerId2 > ServerId1 && ServerId3 > ServerId1)
{
return ServerId1;
}
else if (ServerId1 == ServerId3 && ServerId1 > ServerId2 && ServerId1 > ServerId3)
{
return ServerId1;
}
}
}
我在方法中收到错误(并非所有代码路径都返回值)。此方法返回我定义的 int 值。但是即使我返回了一个 int 值,也不知道为什么会发生这个错误。任何人都可以帮助我吗?