{"id":1356,"date":"2013-01-13T22:52:00","date_gmt":"2013-01-13T21:52:00","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=1356"},"modified":"2013-01-13T22:52:00","modified_gmt":"2013-01-13T21:52:00","slug":"hashsetadd-vegtelen-ciklus","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2013\/01\/13\/hashsetadd-vegtelen-ciklus\/","title":{"rendered":"HashSet.Add v\u00e9gtelen ciklus?"},"content":{"rendered":"<p>HashSetbe akartam berakni hibernate entit\u00e1sokat, amelyek Equals-sza \u00e9s GetHashCode-ja \u00edgy n\u00e9zett ki:<\/p>\n<p>public virtual bool Equals(EntityBase other)<br \/>\n\t\t{<br \/>\n\t\t\tif (other == null)<br \/>\n\t\t\t{<br \/>\n\t\t\t\treturn false;<br \/>\n\t\t\t}<br \/>\n\t\t\tif (Id == 0)<br \/>\n\t\t\t{<br \/>\n\t\t\t\t\/\/Transient object<br \/>\n\t\t\t\treturn ReferenceEquals(this, other);<br \/>\n\t\t\t}<br \/>\n\t\t\treturn other.Id == Id;<br \/>\n\t\t}<\/p>\n<p>\t\tpublic override bool Equals(object obj)<br \/>\n\t\t{<br \/>\n            if (!(obj is EntityBase))<br \/>\n            {<br \/>\n                return false;<br \/>\n            }<br \/>\n\t\t\treturn Equals((EntityBase)obj);<br \/>\n\t\t}<\/p>\n<p>\t\tpublic override int GetHashCode()<br \/>\n\t\t{<br \/>\n\t\t\treturn Id;<br \/>\n\t\t}<\/p>\n<p>A HashSet.Add-nak beadva egy ilyen entit\u00e1s p\u00e9ld\u00e1nyt az Add soha nem t\u00e9rt vissza, v\u00e9gtelen ciklusba ker\u00fclt. Mi\u00e9rt?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>HashSetbe akartam berakni hibernate entit\u00e1sokat, amelyek Equals-sza \u00e9s GetHashCode-ja \u00edgy n\u00e9zett ki: public virtual bool Equals(EntityBase other) { if (other == null)&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,10,11,4],"tags":[],"class_list":["post-1356","post","type-post","status-publish","format-standard","hentry","category-net","category-c","category-clr","category-szakmai-elet"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1356"}],"version-history":[{"count":1,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1356\/revisions"}],"predecessor-version":[{"id":1357,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1356\/revisions\/1357"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}