Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
i'm trying to see which is the best way or practise for sql string optimizations in c#, mssql. What i'm trying to do is like a crud system where we send the necessary required params such as db name and table and after we have the conditional, for example if its a remove action, we will have an where condition and it can contain more than 1 param so what i wanna know is get the whole params.
Should i accept an array with those conditions or what i must do.
Thanks
Not exactly an answer to your question but you should consider using ORM tool like NHibernate.
With NHibernate, you can accept QueryCriteria or ICriteria from outside world which will do the query accordingly.
Be warned that this will be big change in your application and NHibernate have steep learning curve.
There are also simple micro-ORMs available like Dapper. With it, you can implement Repository pattern by creating Data Access Layer. Refer this link.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
What are the effects of Linq on an application rather than SQL queries?
Is there is any issue in using Linq in case of large amount of data for a long time of period?
What are the behavioral key difference between both?
Simple advantages
Creating in-memory collections
for a number of situations it would be easier to read and write. (note there are some queries that would make more sense in SQL)
Allows you to call C# functionality that you create or from the .net framework to interact with your data.
In some cases it is easier to debug.
For a more in depth and correct answer go to Learning about LINQ
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm interested in your opinions, best thoughts ...
Would you say it's better to just query the database any time you want to retrieve data (even if you know it'll be static), or store the data in server(web) session memory?
On the one hand, storing in memory would allow faster processing of data, and decrease SQL server loads. On the other hand, it can somewhat increase complication of application code, and web server/system resources.
The answer depends (as most do) on your specific needs. If your database has the bandwidth but your web server doesn't, you should do it in SQL. And vice versa. There's no way to recommend anything to anyone without knowing their situation.
You can use static dictionaries to store static data from database.
The benefit of use this is have only one instance of each dictionary and reduce the number of request to the database.
You can refer to this question to see how to implement this.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm new to WPF and MVVM pattern. I've been reading about it and I come to a little doubt.
I'll build an WPF application that mainly does access to a database (oracle), but this access is done by an WebService (DataService). My question is in the Model part.
Should I create a class to each table on the database, on my Model, or should I just use the entities that the service provides me?
My guess is use the entities of the service, and then just do the CRUD operations in my application. But I want your opinion.
Thanks in advance.
It is always a good practice to use your own Models. That way, if the Service changes the structure, you will only need to change one point (where you map the item to your own entity), else you would have to change your whole application
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I gonna write a new Program,
is it better to store my Queries in Views and call them from my C# Code.
Or should i Just execute all SQL queries in my Code.
Which is better for the Performance.
From a performance point of view there is no difference between running a query from C# and accessing a view that is based on the same query; the only difference would be if the view that you are accessing has indexes on it and thus runs faster than your ad-hoc query.
As a good practice is best to use SQL View when extracting data from multiple tables through joins as putting the whole SQL code in C# would look messy and might be more prone to errors.
There are a lot of things to be considered when undertaking this:
1. volume of data - indexed views
2. number of tables involved
3. database structure dynamic - how often you change tables
have fun!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
A bit of background: I've been mostly developing in Java and Javascript for the past years and recently i've been moved to a C# project and tasked with implementing a Data Access Layer for this project. As far as i understood it this DAL will call only stored procedures (so no simple sql queries) and return some value if the stored procedure asks for it.
I apologize if this question has been answered before but i was not able to find anything useful.
What would be the best way to test that a DAL is actually calling these stored procedures and returning the results I am expecting? In Java we used Arquillian for integration tests against the DB and it worked great, however i have not been able to find anything like that for C#.
Any help will be appreciated.
Write unit tests for your DAL using something like nunit. This can then test that the results are as expected.