0

I have a web application (ASP.NET Core / C#) with 3 layers (web/presentation, business logic and data access).

I'm using Entity Framework to retrieve a record from an SQL Server database which is subsequently mapped to my model object. One of the retrieved columns contains an XML string where I need to extract some values from and map them to some properties of my Model object.

Of course the retrieval of the database-record is done in the data access layer; but would you place the parsing from the XML string in the data access layer too (since it's a matter of extracting data) or would you rather place it into the business logic layer (since the data access layer should only deal with the database)?

asked Jul 11, 2017 at 8:38

2 Answers 2

2

Definitely Data Access Layer.
The reason why, have nothing to do with how often structure of xml will change.

The fact that one of the columns contains data serialized as xml is implementation details of data access layer.
Business layer doesn't need to care about how data is saved to the database.

Your business layer should introduce an abstraction of retrieving method where method will return already serialized and ready to use data object.

MyData GetDataById(int id);

Then your Data Access Layer will implement it.

answered Jul 11, 2017 at 10:54
0

You ask:

but would you place the parsing from the XML string in the data access layer too (since it's a matter of extracting data) or would you rather place it into the business logic layer (since the data access layer should only deal with the database)?

Now ask yourself an other question:

Does the XML parsing contain any business logic that might change frequently or does it protect any invariants of your model?

  • If not: place it along the data access layer, since -in my read- this concern belongs to data manipulation/preparation layer.

  • If so: put it the business layer.

Worth remembering: always start simple and add complexity later when the need arises.

answered Jul 11, 2017 at 8:43
1
  • 1
    thank you for your feedback. in this case i'll put the xml-deserialization in the data access layer since it will definitely not change frequently (the structur of the xml has been the same for ages). Commented Jul 11, 2017 at 8:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.