business-logic-layer

Does “Save” method belong to the Business Domain Entity?

佐手、 提交于 2020-01-03 09:21:54
问题 I am not using any ORM. So I am having a debate whether "Save" method actually belongs to a Business Domain entity or should be abstracted in some service that will be handed over the Business Domain Entity for saving ? e.g. class Employee { string Name; DateTime Birth; GetAge() { } Save() { } } OR class Employee { string Name; DateTime Birth; GetAge() { } } SomePersistenceService { Save(Employee emp) { } } 回答1: Since this question is tagged with 'domain-driven-design', you'll need a

Does “Save” method belong to the Business Domain Entity?

牧云@^-^@ 提交于 2020-01-03 09:21:10
问题 I am not using any ORM. So I am having a debate whether "Save" method actually belongs to a Business Domain entity or should be abstracted in some service that will be handed over the Business Domain Entity for saving ? e.g. class Employee { string Name; DateTime Birth; GetAge() { } Save() { } } OR class Employee { string Name; DateTime Birth; GetAge() { } } SomePersistenceService { Save(Employee emp) { } } 回答1: Since this question is tagged with 'domain-driven-design', you'll need a

call service vs dao from another service

和自甴很熟 提交于 2019-12-20 12:44:42
问题 I have User And Role entities and Service, DAO layers for them. I need Role list from UserService. Which layer should I use from UserService? Call list method of RoleService vs RoleDAO ? Which one is common use and why? 回答1: Normally DAO layer is close to database, Service layer is encapsulating your business logic, performing any transactions or other things rather than just calling DAO. Service calling another service is more common because Your RoleService can have some business code

Passing business entities through layers in multi layer architecture

孤街醉人 提交于 2019-12-13 13:07:53
问题 Currently I'm working on a project exploiting multi layer architecture as described in Application Architecture Guide 2.0 with 5 layers(DAL, BLL, Facade, Presentation Layer and Common Layer). Here we have a Business Logic Layer which consists of Business Components and Business Entities(which are entities generated using an O/R Mapper), regularly we need this entities in our presentation layer for binding and presenting data to the user so we bubble this entities up to the Presentation Layer

Linq To Sql - Making a dynamic search for the Application layer without exposing DAL layer as DLL

 ̄綄美尐妖づ 提交于 2019-12-13 02:08:38
问题 Linq to SQL, C#. I have 3 layers: DAL,BL,Application. I want to build functions of search in the BL for each table so those functions get as a parameter 'where' expresstion from the Application layer. The advantage in this approach is one function for each table so the client can search in a free and dynamic way insted of givving him 5 (for example) ways; restrict his search. For that I need to give my Application layer a DLL of my DAL layer. Doing that is not a good approach to solve the

C# anonymous type foreach looping

浪子不回头ぞ 提交于 2019-12-13 00:27:19
问题 I need to loop through the properties of a custom object type that I'm getting back from the database and only show the columns that contain data. This means I cannot simply bind the list of objects to the datagrid. I don't want to loop through each object and see if the column is empty/null and determine in the UI to display it. What I'm thinking is in my business layer before I send the object back I would send an IEnumerable back with only those columns that should be visible. Thus I was

Where to catch exceptions

跟風遠走 提交于 2019-12-12 12:28:20
问题 I have a WCF svc separated into a Service Layer, Business Logic Layer and Data Access Layer. When my DAL encounters an exception, should I catch it there or let it bubble back up to the Service Layer? And why? Please disregard any client involvement for this scenario, I am only concerned with logging the exceptions on the WCF svc. 回答1: It depends also on how you are architecting your solution. For instance, if the DAL and BLL layers are meant to be totally independent components, then they

Logic: Database or Application/2 (constraints check)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 07:15:07
问题 This is a specific version of this question. I want to check if I am inserting a duplicate row. Should I check it programmatically in my application layer: if (exists(obj)) { throw new DuplicateObjectException(); } HibernateSessionFactory.getSession().save(obj); or should I catch the exception thrown by the database layer and triggered when I violate the contraint? try { HibernateSessionFactory.getSession().save(obj); } catch(ConstraintViolationException e) { throw new

Layered Design /Architecture

老子叫甜甜 提交于 2019-12-11 14:49:11
问题 we use html 5/angular SPA with Webapi at the service which communicates with DAL for dataaccess operations Layer flow would be: presentation(html5/angular controllers/service) --> web api --> DAL - -> DB. we do not have BLL project as such. we are thinking to make DAL as combination of BLL + DAL. And we use DTO objects created through t4 templates and they are used for transfer of data between client and web api and DAL (we dont use EF, we use ADO.Net as underlying provider) should we require

How can be controled / coordinated algorithm

穿精又带淫゛_ 提交于 2019-12-11 04:46:38
问题 Below picture is a simple part of complex algorithm. I try to prepare some classes in accordance with algorithm. abstract class Person { public string HasXRecords { get; set; } public int PersonAnotherFeature { get; set; } public List<X> Xs { get; set; } = new List<X>(); } abstract class X { //There will more than 1000 type subX classes } interface IAdder { void AddXToList(); } interface IRemover { void RemoveXFromList(); } class XAdderFactory { private Person _person; public bool