本文整理汇总了C#中System.Data.SqlClient.SqlConnection.ExecuteFor方法的典型用法代码示例。如果您正苦于以下问题:C# SqlConnection.ExecuteFor方法的具体用法?C# SqlConnection.ExecuteFor怎么用?C# SqlConnection.ExecuteFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlConnection
的用法示例。
在下文中一共展示了SqlConnection.ExecuteFor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
protected override void Save(Guid userID, string service, string key, string hashedSaltedSecret)
{
using (var conn = new SqlConnection(StandardSqlStore.ConnectionString))
{
var existing = LoadRegistration(service, key);
conn.Open();
var sqlUser = new DragonRegistration()
{
RegistrationID = Guid.NewGuid(),
UserID = userID,
Service = service,
Key = key,
Secret = hashedSaltedSecret
};
if (existing != null)
{
sqlUser.RegistrationID = existing.RegistrationID;
if (!existing.Key.Equals(key))
throw new InvalidOperationException(
"Trying to attach another account from the already connected service");
conn.ExecuteFor<DragonRegistration>(SQL.SqlUserStore_Update, sqlUser);
}
else
{
conn.ExecuteFor<DragonRegistration>(SQL.SqlUserStore_Insert, sqlUser);
}
}
}
示例2: SetPropertyInternal
protected override void SetPropertyInternal(Guid userID, string key, string val)
{
using (var conn = new SqlConnection(StandardSqlStore.ConnectionString))
{
conn.Open();
var param = new { LID = Guid.NewGuid(), UserID = userID, Key = key, Value = val };
if (conn.ExecuteFor<DragonProfile>(SQL.SqlProfileStore_Update, param) == 0)
{
conn.ExecuteFor<DragonProfile>(SQL.SqlProfileStore_Insert, param);
}
}
}
示例3: RemoveSessionRecord
protected override void RemoveSessionRecord(Guid sessionID)
{
base.RemoveSessionRecord(sessionID);
using (var conn = new SqlConnection(StandardSqlStore.ConnectionString))
{
conn.Open();
conn.ExecuteFor<DragonSession>(SQL.SqlSessionStore_Delete, new { SessionID = sessionID });
}
}
示例4: AddNodeInternal
protected override void AddNodeInternal(Guid parentID, Guid childID)
{
var parents = EnumerateParentNodesInternal(childID);
if (!parents.Contains(parentID))
{
using (var conn = new SqlConnection(StandardSqlStore.ConnectionString))
{
conn.Open();
var param = new DragonPermissionNode() {ParentID = parentID, ChildID = childID};
conn.ExecuteFor<DragonPermissionNode>(SQL.SqlPermissionStore_InsertPermissionNode, param);
}
}
RebuildTree();
}
示例5: SaveSessionRecord
protected override void SaveSessionRecord(DragonSession sessionRecord)
{
using (var conn = new SqlConnection(StandardSqlStore.ConnectionString))
{
conn.Open();
SetSessionData(sessionRecord);
var p = new
{
Hash = sessionRecord.Hash,
SessionID = sessionRecord.SessionID,
Expires = sessionRecord.Expires,
Location = sessionRecord.Location,
UserID = sessionRecord.UserID
};
if (conn.ExecuteFor<DragonSession>(SQL.SqlSessionStore_Update, p) == 0)
{
conn.ExecuteFor<DragonSession>(SQL.SqlSessionStore_Insert, p);
}
}
base.SaveSessionRecord(sessionRecord);
}
示例6: AddRightInternal
protected override void AddRightInternal(Guid nodeID, Guid subjectID, string spec, bool inherit)
{
if (EnumerateRightsInternal(nodeID).Any(x =>
x.SubjectID.Equals(subjectID) && x.Spec.Equals(spec)))
{
RemoveRightInternal(nodeID, subjectID, spec);
}
using (var conn = new SqlConnection(StandardSqlStore.ConnectionString))
{
conn.Open();
var param = new DragonPermissionRight()
{
LID = Guid.NewGuid(),
NodeID = nodeID,
SubjectID = subjectID,
Spec = spec,
Inherit = inherit
};
conn.ExecuteFor<DragonPermissionRight>(SQL.SqlPermissionStore_InsertPermissionRight, param);
}
RebuildTree();
}
示例7: RemoveRightInternal
protected override void RemoveRightInternal(Guid nodeID, Guid subjectID, string spec)
{
var candidate = EnumerateRightsInternal(nodeID).FirstOrDefault(x =>
x.SubjectID.Equals(subjectID) && x.Spec.Equals(spec));
if (candidate == null)
throw new RightDoesNotExistException();
using (var conn = new SqlConnection(StandardSqlStore.ConnectionString))
{
conn.Open();
var param = new
{
LID = candidate.LID
};
conn.ExecuteFor<DragonPermissionRight>(SQL.SqlPermissionStore_DeletePermissionRight, param);
}
RebuildTree();
}
示例8: RemoveNodeInternal
protected override void RemoveNodeInternal(Guid parentID, Guid childID)
{
// no parenthood test here because delete will ignore anyway
using (var conn = new SqlConnection(StandardSqlStore.ConnectionString))
{
conn.Open();
var param = new { ParentID = parentID, ChildID = childID };
conn.ExecuteFor<DragonPermissionNode>(SQL.SqlPermissionStore_DeletePermissionNode, param);
}
RebuildTree();
}