0

When coding a Data Access Layer I create two groups of classes, one for the data entities and one for the CRUD operations, whenever I use a class from the second group, I instance that class before using any method from it, these CRUD classes don't have any member, they just have methods and functions.

Taking into account that the app is an Web one, my question is, Is it good to implement these methods/functions inside the CRUD classes as static?

Because they don't have members and are only use to perform database operations, Might they still conflict when used by several users at the same time or there could be any other problem?

jecarfor
  • 498
  • 8
  • 22

1 Answers1

0

Might they still conflict when used by several users at the same time or there could be any other problem?

No, each method call operates on its own stack. It's not like multiple calls to the same static method can influence each other (as long as you don't access static fields inside them, or call other static methods that do). See Are static methods thread safe.

However, you may want to refrain from using static as much as possible. It actively harms testability, for example. See When to use static classes in C#.

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272