private DataSet ExecuteQuery(DataFeed feed, ScriptParameters parameters) { DataSet ds = new DataSet(); DataTable dt = null; string sql = feed.FeedQuery; string name = feed.FeedName; if (parameters != null) { name = parameters.Replace(name); } ds.DataSetName = name; if (feed.FeedType == DataFeedType.SQL) { var command = ReadOnlyDataCommand.Create(CommandType.Text); if (parameters != null) { sql = parameters.Replace(sql); command.Param(parameters); } command.FillDataSet(ds, sql); if (ds.Tables.Count > 0) { ds.Tables[0].TableName = "default"; } } else { ScriptResult result = ScriptEngine.Run(feed.FeedQuery, parameters); if (result.Exception != null) { throw result.Exception; } foreach (var kvp in result.DataSet) { dt = kvp.Value.AsDataTable(); dt.TableName = kvp.Key; ds.Tables.Add(dt); } } return(ds); }
public static DataCommandBase ReadOnlyCommand(CommandType type = CommandType.StoredProcedure) => ReadOnlyDataCommand.Create(type);