关于PetShop一个问题!
public int GetUniqueID(string userName, bool isAuthenticated, bool ignoreAuthenticationType, string appName) {
string sqlSelect = "SELECT UniqueID FROM Profiles WHERE Username = @Username AND ApplicationName = @ApplicationName ";
SqlParameter[] parms = {
new SqlParameter( "@Username ", SqlDbType.VarChar, 256),
new SqlParameter( "@ApplicationName ", SqlDbType.VarChar, 256)};
parms[0].Value = userName;
parms[1].Value = appName;
if(!ignoreAuthenticationType) {
sqlSelect += " AND IsAnonymous = @IsAnonymous ";
Array.Resize <SqlParameter> (ref parms, parms.Length + 1);
parms[2] = new SqlParameter( "@IsAnonymous ", SqlDbType.Bit);
parms[2].Value = !isAuthenticated;
}
int uniqueID = 0;
object retVal = null;
retVal = SqlHelper.ExecuteScalar(SqlHelper.ConnectionStringProfile, CommandType.Text, sqlSelect, parms);
if(retVal == null)
uniqueID = CreateProfileForUser(userName, isAuthenticated, appName);
else
uniqueID = Convert.ToInt32(retVal);
return uniqueID;
这段代码主要是用来干嘛的呀。ignoreAuthenticationType代表什么呢,
------解决方案--------------------看代码应该用来看传哪种身份的验证的
if(!ignoreAuthenticationType) {
sqlSelect += " AND IsAnonymous = @IsAnonymous ";
Array.Resize <SqlParameter> (ref parms, parms.Length + 1);
parms[2] = new SqlParameter( "@IsAnonymous ", SqlDbType.Bit);
parms[2].Value = !isAuthenticated;
}