{"id":1000,"date":"2010-02-01T16:23:34","date_gmt":"2010-02-01T15:23:34","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=1000"},"modified":"2010-02-01T16:23:34","modified_gmt":"2010-02-01T15:23:34","slug":"ef-ssdl-alapu-felhasznaloi-bemenet-ellenorzes","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2010\/02\/01\/ef-ssdl-alapu-felhasznaloi-bemenet-ellenorzes\/","title":{"rendered":"EF SSDL alap\u00fa felhaszn\u00e1l\u00f3i bemenet ellen\u0151rz\u00e9s"},"content":{"rendered":"<p>A k\u00f6vetkez\u0151n t\u00f6r\u00f6m a fejem. Az Entity Framework SSDL-j\u00e9ben defini\u00e1lva vannak az entit\u00e1s property-k alapvet\u0151 jellemz\u0151i: null\u00e1zhat\u00f3s\u00e1g, max hossz. Ezeket a GUI-n ki kell k\u00e9nyszer\u00edteni. Nyilv\u00e1n vannak \u00f6sszetettebb valid\u00e1l\u00e1si szab\u00e1lyok, de most koncentr\u00e1ljunk ezekre az elemiekre.<br \/>\nUt\u00e1lok minden redundanci\u00e1t egy rendszerben, ez\u00e9rt azt gondoltam, a szab\u00e1lyokat kiolvasom az EF s\u00e9m\u00e1j\u00e1b\u00f3l, \u00e9s ebb\u0151l t\u00e1pl\u00e1lom meg a valid\u00e1l\u00f3 r\u00e9szeket, \u00edgy nem kell t\u00f6r\u0151dni az egyszer\u0171 valid\u00e1l\u00e1sokkal, automatikusan m\u0171k\u00f6dni fognak.<\/p>\n<p>A k\u00f6vetkez\u0151 kis k\u00f3docska mutatja meg a metaadatok haszn\u00e1lat\u00e1t:<\/p>\n<p>o.ForceLoadingSchemas();<\/p>\n<p>var sspaceEntitySets = o.MetadataWorkspace<br \/>\n       .GetItems<EntityContainer>(DataSpace.SSpace)<br \/>\n       .First().BaseEntitySets.OfType<EntitySet>();<\/p>\n<p>foreach (EntitySet es in sspaceEntitySets)<br \/>\n{<br \/>\n    foreach (EdmProperty p in es.ElementType.Properties)<br \/>\n    {<br \/>\n        ReadOnlyMetadataCollection<Facet> facets = p.TypeUsage.Facets;<br \/>\n        Debug.WriteLine(&#8220;{0} is {1} nullable&#8221;, p.Name, (bool)facets[&#8220;Nullable&#8221;].Value ? &#8220;&#8221; : &#8220;not&#8221;);<br \/>\n        if (facets.Contains(&#8220;MaxLength&#8221;))<br \/>\n        {<br \/>\n            Debug.WriteLine(&#8220;{0} MaxLenght is {1}&#8221;, p.Name, (int)facets[&#8220;MaxLength&#8221;].Value);<br \/>\n        }<br \/>\n        Debug.WriteLine(&#8220;{0} is {1} nullable&#8221;, p.Name, (bool)facets[&#8220;Nullable&#8221;].Value ? &#8220;&#8221; : &#8220;not&#8221;);<br \/>\n    }<br \/>\n}<\/p>\n<p>A ForceLoadingSchemas az ObjectContext partial class\u00e1ban van:<\/p>\n<p>public void ForceLoadingSchemas()<br \/>\n{<br \/>\n    CreateQuery<BusinessEntity>(&#8220;AdventureWorks2008Entities3.BusinessEntities&#8221;).ToTraceString();<br \/>\n}<\/p>\n<p>Csin\u00e1lt m\u00e1r valaki ilyet? Van benne valami csapda, amit most nem l\u00e1tok?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A k\u00f6vetkez\u0151n t\u00f6r\u00f6m a fejem. Az Entity Framework SSDL-j\u00e9ben defini\u00e1lva vannak az entit\u00e1s property-k alapvet\u0151 jellemz\u0151i: null\u00e1zhat\u00f3s\u00e1g, max hossz. Ezeket a GUI-n&#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,25,6,74,4],"tags":[],"class_list":["post-1000","post","type-post","status-publish","format-standard","hentry","category-net","category-adonet","category-adatbazisok","category-entity-framework","category-szakmai-elet"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1000","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=1000"}],"version-history":[{"count":1,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1000\/revisions"}],"predecessor-version":[{"id":1001,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1000\/revisions\/1001"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}