dto

POCO's, DTO's, DLL's and Anaemic Domain Models

爱⌒轻易说出口 提交于 2019-12-02 15:38:42
I was looking at the differences between POCO and DTO (It appears that POCO's are dto's with behaviour (methods?))and came across this article by Martin Fowler on the anaemic domain model. Through lack of understanding, I think I have created one of these anaemic domain models. In one of my applications I have my business domain entities defined in a 'dto' dll. They have a lot of properties with getter's and setter's and not much else. My business logic code (populate, calculate) is in another 'bll' dll, and my data access code is in a 'dal' dll. 'Best practice' I thought. So typically I

Entity Framework + AutoMapper ( Entity to DTO and DTO to Entity )

那年仲夏 提交于 2019-12-02 14:56:13
I've got some problems using EF with AutoMapper. =/ for example : I've got 2 related entities ( Customers and Orders ) and they're DTO classes : class CustomerDTO { public string CustomerID {get;set;} public string CustomerName {get;set;} public IList< OrderDTO > Orders {get;set;} } class OrderDTO { public string OrderID {get;set;} public string OrderDetails {get;set;} public CustomerDTO Customers {get;set;} } //when mapping Entity to DTO the code works Customers cust = getCustomer(id); Mapper.CreateMap< Customers, CustomerDTO >(); Mapper.CreateMap< Orders, OrderDTO >(); CustomerDTO custDTO =

Moq框架简单使用

孤者浪人 提交于 2019-12-02 14:39:16
Moq框架简单使用 系列目录 Moq库简介及安装 Moq简介 Moq是.net平台下的一个非常流行的模拟库,只要有一个接口它就可以动态生成一个对象,底层使用的是Castle的动态代理功能. 它的流行赖于依赖注入模式的兴起,现在越来越多的分层架构使用依赖注入的方式来解耦层与层之间的关系.最为常见的是数据层和业务逻辑层之间的依赖注入,业务逻辑层不再强依赖数据层对象,而是依赖数据层对象的接口,在IOC容器里完成依赖的配置. 这种解耦给单元测试带来了巨大的便利,使得对业务逻辑的测试可以脱离对数据层的依赖,单元测试的粒度更小,更容易排查出问题所在. 大家可能都知道,数据层的接口往往有很多方法,少则十几个,多则几十个.我们如果在单元测试的时候把接口切换为假实现,即使实现类全是空也需要大量代码,并且这些代码不可重用,一旦接口层改变不但要更改真实数据层实现还要修改这些专为测试做的假实现.这显然是不小的工作量. 幸好有Moq,它可以在编译时动态生成接口的代理对象.大大提高了代码的可维护性,同时也极大减少工作量. 除了动态创建代理外,Moq还可以进行行为测试,触发事件等. Moq安装 Moq安装非常简单,在Nuget里面搜索moq,第一个结果便是moq框架,点击安装即可. Moq简单使用 本示例中要使用到的代码如下 public class MyDto { public string Name {

Value Objects in CQRS - where to use

风流意气都作罢 提交于 2019-12-02 14:08:26
Let's say we have CQRS-inspired architecture, with components such as Commands, Domain Model, Domain Events, Read Model DTOs. Of course, we can use Value Objects in our Domain Model. My question is, should they also be used in: Commands Events DTOs I haven't seen any examples where Value Objects (VO) are used in the components mentioned above. Instead, primitive types are used. Maybe it's just the simplistic examples. After all, my understanding of VOs use in DDD is that they act as a glue for the whole application. My motivation: Commands. Let's say user submits a form which contains address

DDD using STE vs POCO

烈酒焚心 提交于 2019-12-02 10:57:42
Developing n-layered application with DDD (o better DDDD because we are using WCF) using Microsoft technology (where we have full controll of all component), the best choise seems to be STE vs POCO (this last one force the usage of DTOs). That's right? In your opinion make sense the usage of STE with DTOs where we need them? Thanks. I really can recommend Julie Lerman's Programming Entity Framework . She goes in depth about simple poco's, dto's and Self Tracking Entities. Advantages and disadvantages are described. But off course depending a lot on application requirements and personal taste.

Why does ToOptimizedResult throw “Requested feature is not implemented.” on Mono?

て烟熏妆下的殇ゞ 提交于 2019-12-02 08:46:19
问题 I am building my ServiceStack 4.0.8 service using Visual Studio. On Windows everything works perfectly, but when I try to run on Mono 2.10.8.1 / Ubuntu 13.10 with NGINX 1.4.1 and fastcgi-server4. I get an exception: The requested feature is not implemented. at System.Web.HttpContextWrapper.GetService (System.Type serviceType) [0x00000] in :0 at ServiceStack.Host.RequestPreferences.GetWorker (System.Web.HttpContextBase context) [0x00000] in :0 at ServiceStack.Host.RequestPreferences.get

Query DTO objects through WCF with linq to sql backend

烈酒焚心 提交于 2019-12-02 07:22:27
问题 I am working on a project where we need to create complex queries against a WCF service. The service uses linq to sql at the backend and projects queries to data transfer objects like this: dbContext.GetQueryable() .Where(x => x.Id == formatId) .Select(x => FormatHelper.PopulateMSFormat(x)) .ToList(); What I want to do is to specify a query on the client side, lets say i want to query all formats having a certain property or a couple of them. Something in the style of this: var assets =

How to convert sqldatareader to list of dto's?

旧时模样 提交于 2019-12-02 06:52:39
问题 I just started moving all my ado.net code from the asp.net pages to repo's and created dto's for each table (manually), but now I don't know what is a good efficient way to convert a sqldatareader to a list of my dto objects? For example sake, my dto is Customer. I am using webforms and I am NOT using an ORM. I would like to start slow and work my way up there. 回答1: Here a short example on how you can retrieve your data using a data reader: var customers = new List<Customer>(); string sql =

Query DTO objects through WCF with linq to sql backend

 ̄綄美尐妖づ 提交于 2019-12-02 05:34:03
I am working on a project where we need to create complex queries against a WCF service. The service uses linq to sql at the backend and projects queries to data transfer objects like this: dbContext.GetQueryable() .Where(x => x.Id == formatId) .Select(x => FormatHelper.PopulateMSFormat(x)) .ToList(); What I want to do is to specify a query on the client side, lets say i want to query all formats having a certain property or a couple of them. Something in the style of this: var assets = client.QueryForAssets().Where(x => (x.name == "Test" || x == "Arne") && x.doe == "john"); Iam aware that I

Why does ToOptimizedResult throw “Requested feature is not implemented.” on Mono?

杀马特。学长 韩版系。学妹 提交于 2019-12-02 04:27:28
I am building my ServiceStack 4.0.8 service using Visual Studio. On Windows everything works perfectly, but when I try to run on Mono 2.10.8.1 / Ubuntu 13.10 with NGINX 1.4.1 and fastcgi-server4. I get an exception: The requested feature is not implemented. at System.Web.HttpContextWrapper.GetService (System.Type serviceType) [0x00000] in :0 at ServiceStack.Host.RequestPreferences.GetWorker (System.Web.HttpContextBase context) [0x00000] in :0 at ServiceStack.Host.RequestPreferences.get_HttpWorkerRequest () [0x00000] in :0 at ServiceStack.Host.RequestPreferences.get_AcceptEncoding () [0x00000]