TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aurovinda Shyamal
1.6k
160
1.8k
need to performance tune by datareader
Dec 31 2019 7:14 AM
Hi,
Below am sending my code and I need some improvement by replacing dataadapter,dataset with data reader:
public DataSet GetEpiInputData(decimal forecastId, decimal scenarioId, decimal? lineId)
{
var result = new DataSet();
using (IndForecastingContext dbContext = new IndForecastingContext())
{
var conn = dbContext.Database.Connection;
var connectionState = conn.State;
List<SqlParameter> spParams = new List<SqlParameter>();
try
{
spParams.Add(new SqlParameter { ParameterName = "@ForecastID", Value = forecastId });
spParams.Add(new SqlParameter { ParameterName = "@ScenarioID", Value = scenarioId });
if (lineId.HasValue)
{
spParams.Add(new SqlParameter { ParameterName = "@LineID", Value = lineId });
}
if (connectionState != ConnectionState.Open)
conn.Open();
DbProviderFactory factory = DbProviderFactories.GetFactory(conn);
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "[dbo].[GetEpiInputData]";
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.Parameters.AddRange(spParams.ToArray());
using (var adapter = factory.CreateDataAdapter())
{
adapter.SelectCommand = cmd;
adapter.Fill(result);
}
}
}
catch (Exception ex)
{
}
finally
{
if (connectionState == ConnectionState.Open)
conn.Close();
}
}
return result;
}
The line I marked as yellow its taking 3 to 4 mnts.when it executes datadapter fills multiple table into datasets.Is there any way to optimize .Finally any how I have to return dataset output.
Reply
Answers (
11
)
API show 400 Bad Request
Its ONLY displaying the last value. Not any values i need...