Join() public method

public Join ( Serenity.Data.Join join ) : SqlQuery
join Serenity.Data.Join
return SqlQuery
        public static SqlQuery EnsureJoin(this SqlQuery query, Join join)
        {
            if (join == null)
            {
                throw new ArgumentNullException("join");
            }

            var ext = (ISqlQueryExtensible)query;

            var joinAlias = join.Name;
            var aliases   = ext.Aliases;

            if (aliases.ContainsKey(joinAlias))
            {
                return(query);
            }

            if (join.Joins != null &&
                join.ReferencedAliases != null)
            {
                foreach (var alias in join.ReferencedAliases)
                {
                    if (String.Compare(alias, joinAlias, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        continue;
                    }

                    Join other;
                    if (join.Joins.TryGetValue(alias, out other))
                    {
                        EnsureJoin(query, other);
                    }
                }
            }

            query.Join(join);

            return(query);
        }