You need to increase
Timeoutproperty to get result.
If it is ADO.NET:
SqlCommand command = new SqlCommand();
command.CommandTimeout = 120;
If it is EntityFramework:
this.context.CommandTimeout = 120;
Secondly you need to find why your SP/Function is taking time to execute. You can use SQl Server profiler to get exact issue. Please go through below link that will help you to improve performance.
Top 10 steps to optimize data access in SQL Server: Part I (use indexing)[
^]