public static void AddJoin(DQueryDom mainDom, JoinAlias selfAlias) { var root = mainDom.From.RootSource.Alias; var datediff = DQExpression.DateDiff(DQExpression.Field(selfAlias, "Date"), DQExpression.Field(root, "Time")); mainDom.From.AddJoin(JoinType.Left, new DQDmoSource(selfAlias), DQCondition.And( DQCondition.EQ(DQExpression.Value(-1), datediff), DQCondition.EQ(selfAlias, "Goods_ID", root, "Goods_ID"))); }