{"action":"closed","issue":{"url":"https://api.github.com/repos/schotime/NPoco/issues/137","labels_url":"https://api.github.com/repos/schotime/NPoco/issues/137/labels{/name}","comments_url":"https://api.github.com/repos/schotime/NPoco/issues/137/comments","events_url":"https://api.github.com/repos/schotime/NPoco/issues/137/events","html_url":"https://github.com/schotime/NPoco/issues/137","id":45572793,"number":137,"title":"Why Insert Timeout？","user":{"login":"tengithub","id":4187686,"avatar_url":"https://avatars.githubusercontent.com/u/4187686?v=3","gravatar_id":"","url":"https://api.github.com/users/tengithub","html_url":"https://github.com/tengithub","followers_url":"https://api.github.com/users/tengithub/followers","following_url":"https://api.github.com/users/tengithub/following{/other_user}","gists_url":"https://api.github.com/users/tengithub/gists{/gist_id}","starred_url":"https://api.github.com/users/tengithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tengithub/subscriptions","organizations_url":"https://api.github.com/users/tengithub/orgs","repos_url":"https://api.github.com/users/tengithub/repos","events_url":"https://api.github.com/users/tengithub/events{/privacy}","received_events_url":"https://api.github.com/users/tengithub/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-10-12T08:04:43Z","updated_at":"2015-06-14T11:35:25Z","closed_at":"2015-06-14T11:35:25Z","body":"When I was in use Npoco, I met a strange question\r\n\r\nMy Code：\r\n```C#\r\nusing NPoco;\r\n\r\n//my Database Model\r\n    [TableName(\"TB_ArtAndCol\")]\r\n    [PrimaryKey(\"ColumnID,ArticleID\")]\r\n    class ArtAndCol {\r\n        public int ColumnID { get; set; }\r\n        public int ArticleID { get; set; }\r\n    }\r\n\r\n    [TableName(\"TB_Article\")]\r\n    [PrimaryKey(\"ID\", AutoIncrement = true)]\r\n    public class Article {\r\n        public int ID { get; set; }\r\n        public string Title { get; set; }\r\n    }\r\n\r\n    public abstract class BaseServer<TB> {\r\n        protected static IDatabase DB = new Database(\"DataConnection\");\r\n\r\n        public virtual bool IsExist(TB entity) {\r\n            return !(DB.IsNew<TB>(entity));\r\n        }\r\n        public virtual TB Single(object primaryKey) {\r\n            return DB.SingleOrDefaultById<TB>(primaryKey);\r\n        }\r\n\r\n        public virtual void Update(TB entity) {\r\n            DB.Update(entity);\r\n        }\r\n\r\n        public virtual TB Insert(TB entity) {\r\n            DB.Insert<TB>(entity);\r\n            return entity;\r\n        }\r\n    }\r\n\r\n    public class ArticleServer : BaseServer<Article> {\r\n        private void SetArtAndCol(int artID, int? colProtID, int? colID) {\r\n            var aacs = new ArtAndColServer();\r\n            var aac = new ArtAndCol { ArticleID = artID, ColumnID = colID.Value };\r\n            if (!aacs.IsExist(aac)) {\r\n                aacs.Insert(aac); //run here, prompt error: timeout\r\n            }\r\n        }\r\n\r\n        public override void Update(Article entity) {\r\n            using (var trans = DB.GetTransaction()) {\r\n                base.Update(entity);\r\n\r\n                SetArtAndCol(entity.ID, entity.ColProtID, entity.ColID);\r\n\r\n                trans.Complete();\r\n            }\r\n        }\r\n    }\r\n\r\n    public class ArtAndColServer : BaseServer<ArtAndCol> {\r\n        public void Delete(int articleID, int columnID) {\r\n            DB.Delete<ArtAndCol>(new ArtAndCol { ArticleID = articleID, ColumnID = columnID });\r\n        }\r\n\r\n        public ArtAndCol Insert(int articleID, int columnID) {\r\n            var m = new ArtAndCol { ArticleID = articleID, ColumnID = columnID };\r\n            return base.Insert(m);\r\n        }\r\n    }\r\n\r\n//Console\r\n    class Program {\r\n        static void Main(string[] args) {\r\n            ArticleServer arts = new ArticleServer();\r\n            var a = arts.Single(3);\r\n            a.ColID = 4;\r\n            arts.Update(a);\r\n        }\r\n    }\r\n```\r\nWhen I run the code, it prompt timeout. I can't insert data to ‘ArtAndCol’  table. \r\n\r\nAfter I debug, the problem on Database.ExecuteNonQueryHelper()‘s cmd.ExecuteNonQuery()\r\n\r\n```\r\n       internal int ExecuteNonQueryHelper(IDbCommand cmd)\r\n        {\r\n            DoPreExecute(cmd);\r\n            var result = cmd.ExecuteNonQuery(); //here\r\n            OnExecutedCommand(cmd);\r\n            return result;\r\n        }\r\n```"}}