protected override void ModifyFields(IRewriteSession refactorRewriteSession) { var rewriter = refactorRewriteSession.CheckOutModuleRewriter(_targetQMN); rewriter.RemoveVariables(SelectedFields.Select(f => f.Declaration) .Cast <VariableDeclaration>()); if (_stateUDTField.IsExistingDeclaration) { _stateUDTField.AddMembers(SelectedFields.Cast <IConvertToUDTMember>()); rewriter.Replace(_stateUDTField.AsTypeDeclaration, _stateUDTField.TypeDeclarationBlock(_indenter)); } }
/// <summary> /// Create service model from api model /// </summary> public PublishedDataSetEventsModel ToServiceModel() { return(new PublishedDataSetEventsModel { Id = Id, DiscardNew = DiscardNew, EventNotifier = EventNotifier, BrowsePath = BrowsePath, Filter = Filter?.ToServiceModel(), QueueSize = QueueSize, MonitoringMode = MonitoringMode, TriggerId = TriggerId, SelectedFields = SelectedFields? .Select(f => f.ToServiceModel()) .ToList() }); }
//[System.Diagnostics.DebuggerStepThrough] public string ToSQLString(string Quotes, string paramPrefix, List <XSqlCommandParam> Params, ISqlCompiler compiler) { var ret = ""; if (this.source == null) { if (SelectedFields == null || this.SelectedFields.Count == 0) { if (this.filter == null) { ret = "select * From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler); } else { ret = "select * From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } } else { if (this.filter == null) { ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler); } else { ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } } } else { if (SelectedFields == null || this.SelectedFields.Count == 0) { if (this.filter == null) { ret = "select * From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler); } else { ret = "select * From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } } else { if (this.filter == null) { ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler); } else { ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler); } } } if (this.GroupByFields != null) { ret += " Group By " + string.Join(",", this.GroupByFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))); } if (ret != "") { return(ret); } throw new NotImplementedException(); }