N-tier architecture without using a dataset (a dataset sounds bad for performance)

I read books, articles, textbooks and all such things about n-tier architecture, and I try to apply the famous 3-tier (DAL, BLL, PL), and I just got into the game, in fact I read a lot about how it’s bad to load the entire database into memory (which makes the data set) specially when I need to look at information about an element that needs to be extracted from 5 tables or something else, so it will be a lot, and I want only ONE RECORDING! and the only time I need a lot of records. It will not be so much, and it will extract very simple information (id, name, address) something like this!

Do you think it's better to find another way to create DAL and BLL without datasets? or is the data set better? if the dataset is not suitable for performance, etc., do you have any material to teach me how to do this?

+3
source share
5 answers

Most of the above is solid advice. I agree that if you plan to invest time to create an N-Tier application, you should consider looking for an ORM solution. If you're building .NET technologies, EF4 is a very good approach to creating DALs.

, DAL/BLL. DataSets .NET 3 4, . DAL . List<T> or IQueryable<T>. IQueryable - , , BLL DAL.

, . (, CustomerRepository, EmployeeRepository) , .

, :

Repository<TEntity> : IRepository<TEntity> where TEntity : ITrackable

DAL, nCommon. Entity Framework POCOs: http://blog.tonysneed.com/2010/02/19/trackable-dtos-taking-n-tier-a-step-further-with-ef4/

, DAL , .

. . , sqldatareaders. , EF4 N-Layer, .


[EDIT]

, , .

, . , , . , : , , , , .

. Malcolm Gladwell Outliers , - 10 000 . .:)

, , - Head First - Design Patterns. OOD , . , : " , , , !" , ; , . ( ).

, , , . , , ... .NET. , , . , , .

, Microsoft . - .

Entity Framework EF4. ORM - "" , -. , , :

SqlDataReader

"SELECT * FROM Users WHERE Users.UserId = 1"

ORM SQL. ORM , . - :

User user = EFContext.Users.Where(u => u.UserId == 1).SingleOrDefault();

ORM SQL . ORM (MSSQL, Oracle, MySql) .

, ORM BLL. , :

using (var repository = new Repository<User>()) { User user = repository.Where(u => u.UserId == 1).SingleOrDefault(); }

ORM . : , ( , - ) , .

, .


[ 2]

, , . :

, ORM, List<T>, IQueryable<T>, T . , Entity POCO. POCO - , , . . .

, -, , , List<T>, BindingList<T>, , DTO .

DTO , . DTO . :

[DataContract]
public sealed class UserSummary : IDto
{
[DataMember]
public String FirstName { get; private set; }

[DataMember]
public String LastName { get; private set; }

[DataMember]
public UserProfile Profile { get; private set; }

public UserSummary(String firstName, String lastName, UserProfile profile)
{
    FirstName = firstName;
    LastName = lastName;
    Profile = profile;
}

}

. POCOs , : AutoMapper. POCO, , .

. DTO -. , , , .

, , List<IDto>, ValidationResults Microsoft , .

, . NLayer, , . , . .

+5
+1

Datasets. , , .

... , Command Adapter, . , , - , .

- NHibernate, Linq to SQL Entity Framework, ; ADO.NET .

0

, . , , . , , , , .

, , - .

0

1000 , 1. , SQL, .

I have been involved in .Net for a long time. If I were you, I would spend some time and look at the Entity Framework, Entity Spaces (my preferences), nHibernate or ORM of some way.

They make life easier, and if done right, you can still have a nice loosely coupled architecture.

In short, datasets are pretty lame, and they all seem powerful, but usually do for poor architecture.

0
source

Source: https://habr.com/ru/post/1774744/