We are developing a project in ASP.NET/C#
, which is not a very large project, but a significant one. Currently, we have developed several pages. From today, I speak in terms of one page. The approach is followed for all pages that have been developed so far.
In the code behind my page, we directly use Linq To SQL
queries. insert operation
, queries
performed to populate dropdownlists
, and other database
related operations are used in the code behind them.
We use functions. The same goes for other pages.
My question is, should I include them in class
files and then create objects
and call the appropriate methods to perform my actions?
If so, we must create one class
or create one class on the page. This is called creating a Data Access Layer
.
Can someone help me suggest the right way to do this?
Is this approach a good programming practice.
This is a simple function that we use in our code for
public void AccountTypeFill() { //Get the types of Account ie Entity and individual var acc = from type in dt.mem_types select type.CustCategory; if (acc != null) { NewCustomerddlAccountType.DataSource = acc.Distinct().ToList(); NewCustomerddlAccountType.DataBind(); } }
Can someone please provide a simple example referencing this query?
Hope my question makes sense. Any suggestions are welcome.
source share