{"id":3130,"date":"2015-04-19T18:09:37","date_gmt":"2015-04-19T18:09:37","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=3130"},"modified":"2015-04-19T18:09:37","modified_gmt":"2015-04-19T18:09:37","slug":"writing-your-own-cqlinq-ndepend-functions","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/writing-your-own-cqlinq-ndepend-functions\/","title":{"rendered":"Writing your own CQLinq (NDepend) functions"},"content":{"rendered":"<p><em>To be honest this is well documented on NDpend&#8217;s web site &#8211; <a href=\"http:\/\/www.ndepend.com\/docs\/cqlinq-syntax#Proc\" title=\"Defining a procedure in a query\" target=\"_blank\">Defining a procedure in a query<\/a>.<\/em><\/p>\n<p>A previous post on CQLinq covered using a query to filter types for use in another CQLinq query. An alternate might be to create your own filter function.<\/p>\n<p>To create a function in CQLinq we can simply create a <strong>Func<\/strong> variable and then create the code that is called when the variable is used, for example<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nlet Ignore = new Func&lt;IField, bool&gt;(f =&gt; \r\n   f.ParentAssembly.Name == &quot;ThirdPartAssembly&quot;\r\n)\r\n<\/pre>\n<p>Now to use the function we simply use it like this <\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nfrom f in JustMyCode.Fields where\r\n   !Ignore(f)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To be honest this is well documented on NDpend&#8217;s web site &#8211; Defining a procedure in a query. A previous post on CQLinq covered using a query to filter types for use in another CQLinq query. An alternate might be to create your own filter function. To create a function in CQLinq we can simply [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[100],"tags":[],"class_list":["post-3130","post","type-post","status-publish","format-standard","hentry","category-ndepend"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=3130"}],"version-history":[{"count":1,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3130\/revisions"}],"predecessor-version":[{"id":3131,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3130\/revisions\/3131"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=3130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=3130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=3130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}