当前位置: 首页>>代码示例>>C#>>正文


C# SqlConnection.ExecuteFor方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:jbinder,项目名称:dragon,代码行数:31,代码来源:SqlUserStore.cs

示例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);
         }
     }
 }
开发者ID:jbinder,项目名称:dragon,代码行数:12,代码来源:SqlProfileStore.cs

示例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 });
            }
        }
开发者ID:jbinder,项目名称:dragon,代码行数:10,代码来源:SqlSessionStore.cs

示例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();
        }
开发者ID:jbinder,项目名称:dragon,代码行数:16,代码来源:SqlPermissionStore.cs

示例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);
        }
开发者ID:jbinder,项目名称:dragon,代码行数:23,代码来源:SqlSessionStore.cs

示例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();
        }
开发者ID:jbinder,项目名称:dragon,代码行数:24,代码来源:SqlPermissionStore.cs

示例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();
        }
开发者ID:jbinder,项目名称:dragon,代码行数:20,代码来源:SqlPermissionStore.cs

示例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();
        }
开发者ID:jbinder,项目名称:dragon,代码行数:13,代码来源:SqlPermissionStore.cs


注:本文中的System.Data.SqlClient.SqlConnection.ExecuteFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。