private string CreateJoinJoined(ManyToManyJoinAttribute manyToManyJoinAttribute) { return(string.Format("{0} on {0}.{1} = {2}.{3}{4}", manyToManyJoinAttribute.JoinedTable, manyToManyJoinAttribute.JoinedTableField, manyToManyJoinAttribute.CommunicationTable, manyToManyJoinAttribute.CommunicationTableJoinedTableField, manyToManyJoinAttribute.AddOnType == AddOnType.ForJoined ? GetAddOnClauses(manyToManyJoinAttribute) : string.Empty)); }
public void CreateTest() { var attr = new ManyToManyJoinAttribute("CurrentTableField", JoinType.Left, "JoinedTable", "CommunicationTable", "CommunicationTableCurrentTableField", "CommunicationTableJoinedTableField") { SelectColumns = "CurrentTable:Id,Name;CommunicationTable:Required;JoinedTable:Id,Name", CurrentTable = "CurrentTable", JoinedTableField = "Id", CurrentTableField = "CurrentTableField", }; var creator = new ManyToManyClauseCreator(); var res = creator.Create(attr); Assert.IsTrue(res.HasJoin); Assert.AreEqual(JoinType.Left, res.JoinType); Assert.AreEqual(2, res.JoinSqls.Count()); Assert.AreEqual(5, res.SelectsSql.Count()); Assert.AreEqual("SplitOnJoinedTableId", res.Splitter); Assert.AreEqual("CurrentTable.Id", res.SelectsSql.ToArray()[0]); Assert.AreEqual("CurrentTable.Name", res.SelectsSql.ToArray()[1]); Assert.AreEqual("CommunicationTable.Required", res.SelectsSql.ToArray()[2]); Assert.AreEqual("JoinedTable.Id", res.SelectsSql.ToArray()[3]); Assert.AreEqual("JoinedTable.Name", res.SelectsSql.ToArray()[4]); Assert.AreEqual( "CommunicationTable on CommunicationTable.CommunicationTableCurrentTableField = CurrentTable.CurrentTableField", res.JoinSqls.ToArray()[0]); Assert.AreEqual("JoinedTable on JoinedTable.Id = CommunicationTable.CommunicationTableJoinedTableField", res.JoinSqls.ToArray()[1]); }
private string CreateJoinJoined(ManyToManyJoinAttribute attribute) { if (!String.IsNullOrEmpty(attribute.JoinedTableAlias)) { return(string.Format("{0} {1} on {1}.{2} = {3}.{4}{5}", attribute.JoinedTable, attribute.JoinedTableAlias, attribute.JoinedTableField, !String.IsNullOrEmpty(attribute.CommunicationTableAlias) ? attribute.CommunicationTableAlias : attribute.CommunicationTable, attribute.CommunicationTableJoinedTableField, attribute.AddOnType == AddOnType.ForJoined ? GetAddOnClauses(attribute) : string.Empty)); } return(string.Format("{0} on {0}.{1} = {2}.{3}{4}", attribute.JoinedTable, attribute.JoinedTableField, attribute.CommunicationTable, attribute.CommunicationTableJoinedTableField, attribute.AddOnType == AddOnType.ForJoined ? GetAddOnClauses(attribute) : string.Empty)); }