Summary

Class:FakeXrmEasy.Extensions.QueryExpressionExtensions
Assembly:FakeXrmEasy
File(s):F:\Git\fake-xrm-easy\FakeXrmEasy.Shared\Extensions\QueryExpressionExtensions.cs
Covered lines:13
Uncovered lines:1
Coverable lines:14
Total lines:36
Line coverage:92.8%
Branch coverage:75%

Metrics

MethodCyclomatic ComplexitySequence CoverageBranch Coverage
GetEntityNameFromAlias(...)388.8980
Clone(...)1100100

File(s)

F:\Git\fake-xrm-easy\FakeXrmEasy.Shared\Extensions\QueryExpressionExtensions.cs

#LineLine coverage
 1using Microsoft.Xrm.Sdk.Query;
 2using System.Linq;
 3
 4namespace FakeXrmEasy.Extensions
 5{
 6    public static class QueryExpressionExtensions
 7    {
 8        public static string GetEntityNameFromAlias(this QueryExpression qe, string sAlias)
 4529        {
 45210             if (sAlias == null)
 011                return qe.EntityName;
 12
 45213            var linkedEntity = qe.LinkEntities
 114514                            .Where(le => le.EntityAlias != null && le.EntityAlias.Equals(sAlias))
 45215                            .FirstOrDefault();
 16
 45217             if (linkedEntity != null)
 43518            {
 43519                return linkedEntity.LinkToEntityName;
 20            }
 21
 22            //If the alias wasn't found, it means it  could be any of the EntityNames
 1723            return sAlias;
 45224        }
 25
 26        /// <summary>
 27        /// Makes a deep clone of the Query Expression
 28        /// </summary>
 29        /// <param name="qe">Query Expression</param>
 30        /// <returns></returns>
 31        public static QueryExpression Clone(this QueryExpression qe)
 165932        {
 165933            return qe.Copy();
 165934        }
 35    }
 36}