Been reading through a lot of Q's and posts and see that subqueries/nested queries/query composition will not be supported until the next version. However I'm not sure if that is what I need, in my head it I would write it that way but I might be complicating things.
I imagine it like
WARN IF Count > 0 IN
SELECT TYPES WHERE
IsDirectlyUsing "MTNE.Web.OneWeb.^.*\p{Proxy}+$" IN
SELECT TYPES WHERE DeriveFrom "System.Web.Services.Protocols.SoapHttpClientProtocol"
So w开发者_开发技巧hat I'd like to do is check if types are directly using other types in a given namespace which has the suffix Proxy, and that the proxy type is derived from SoapHttpClientProtocol. If a type is directly using the proxy type announce a warning.
Suggestions, hints, tips, pointers or answers anyone?
There are several ways to write the query asked with Code Rule over LINQ Query (CQLinq). Certainly the most elegant, concise and optimized way is:
warnif count > 0
let soapClientTypes = Application.Types.Where(t => t.DeriveFrom("System.Web.Services.Protocols.SoapHttpClientProtocol"))
let mnteTypes = Application.Types.WithFullNameLike(@"MTNE.Web.OneWeb.^.*\p{Proxy}+$").ToHashSet()
from t in soapClientTypes.UsingAny(mnteTypes)
select new { t,
mnteTypesUsed = t.TypesUsed.Intersect(mnteTypes) }
Notice how we first define 2 sets, and also use the extension method ToHashSet() to optimize the execution of the Intersect() method.
Notice also the usage of the method UsingAny() that, in a single call, perform a lot of work.
精彩评论