dto

How do I use DTO's with EF, Autofac, and a generic data repository?

回眸只為那壹抹淺笑 提交于 2019-12-23 05:22:09
问题 How do I use DTO's with EF, Autofac, and a generic data repository? I'm in the process of setting up a new project and have configured my DI/IoC (Autofac), using a generic repository for data access through EF, and created an OData service endpoint, ContentTypesController . Here's the top part of the controller: public class ContentTypesController : ODataController, IContentTypesController { // add repository reference private readonly IRepository<ContentType> _repository; private

Is it possible to use ODataQueryOptions with DTO's?

折月煮酒 提交于 2019-12-23 03:43:09
问题 ContentType --> EF model ContentTypes --> DTO In my OData controller: public Task<IQueryable<ContentTypes>> Get(ODataQueryOptions<ContentTypes> options) { var result = options.ApplyTo(_repository.Query().Get() .Where(u => u.UserId == userId) .OrderBy(o => o.Description)) .Cast<ContentTypes>(); return result; } I get an error 500 when trying to apply the ODataQueryOptions . Since the class already inherits ODataController do I even need to do the options.ApplyTo(...) ? 回答1: The solution for

GWT + entities + JPA + DTO + Dozer

谁都会走 提交于 2019-12-22 12:39:54
问题 I am wondering what is the best way to handle mapping of entity beans (JPA 2) to DTOs. Since you cannot use entity beans "directly" with GWT, you need to handle DTOs instead. I have several entities with various relationships (OneToOne, OneToMany, ManyToMany with a join table etc). Initially i started converting all entities to DTOs by hand with the help of a class MyEntityTransform.java with methods like : static final public CarBean persistant2Bean(CarPersist) { return new CarBean

Using DTO vs Serializating entities

可紊 提交于 2019-12-22 00:14:43
问题 I have already read this thread before asking the question, but this is a pretty old thread and lots of new ways for de serializing the entities are there now. My first question is why we should not use the Entities in the Controller ? If the only reason is waste data travelling across the wire then it should not be an issue because there are ways to avoid this. I am using flexjson.JSONSerializer for de serializing the entity and Gson.fromJSON() for serializing the json into entity instead of

MapStruct implementation is not working in Spring Boot Web Application

点点圈 提交于 2019-12-21 20:33:06
问题 I am a newbie to Spring Boot and MapStruct Tool. Earlier, A Project(written by other team using these technologies) is not starting up. Then, I had made some changes in Mapper Abstract Class but now mapper object is coming as null on application startup. Mapper Abstract Class: @Mapper(componentModel = "spring") public abstract class UserAndEmployeeMapper { public UserAndEmployeeMapper INSTANCE = Mappers.getMapper( UserAndEmployeeMapper.class ); @Mapping(source = "username", target = "name")

QueryDSL projections with @ManyToOne relation

末鹿安然 提交于 2019-12-21 18:28:16
问题 I'm using OpenJPA with QueryDSL, I try to avoid manipulating Tuple objects by using the bean projections features of QueryDSL. I have for example these two Entity, with a @ManyToOne relation. @Entity public class Folder { private Long id; private String name; private String path; @ManyToOne @JoinColumn(name = "FK_FILE_ID") private File file; } @Entity public class File { private Long id; private String fileName; } When I'm executing this query : List<Folder> listFolders = query.from(folder)

QueryDSL projections with @ManyToOne relation

人盡茶涼 提交于 2019-12-21 18:27:09
问题 I'm using OpenJPA with QueryDSL, I try to avoid manipulating Tuple objects by using the bean projections features of QueryDSL. I have for example these two Entity, with a @ManyToOne relation. @Entity public class Folder { private Long id; private String name; private String path; @ManyToOne @JoinColumn(name = "FK_FILE_ID") private File file; } @Entity public class File { private Long id; private String fileName; } When I'm executing this query : List<Folder> listFolders = query.from(folder)

Should a WCF service return an EntityObject or a POCO/DTO class?

◇◆丶佛笑我妖孽 提交于 2019-12-21 12:36:11
问题 I've been looking at a lot of WCF examples using EntityFramework and most of them seem to return some kind of POCO or DTO class to the client. I was wondering why this was since the default EntityObject includes the [DataContract] attributes and implements INotifyPropertyChanged . Is returning a DTO or POCO class better than an EntityObject (or vise versa)? And is there specific instances where it is better to use one return value over another? 回答1: As a best practice, you should definitely

Grails: Can I use domain objects when I don't want to save anything?

旧城冷巷雨未停 提交于 2019-12-21 08:49:12
问题 Some of my domain classes are getting rather rich: They implement an interesting comparable, might have plus, minus, multiply and div, many have some convenient getters which call services and determine complicated things. And most of all, they have the right properties. I am using these both for the normal "database transactions" and also in times when I just want an object that has all those methods but may not want to save it. My teammates are convinced that this is very bad, and advise

Linq to SQL DTOs and composite objects

混江龙づ霸主 提交于 2019-12-21 02:41:31
问题 I am using a similar approach to others in keeping my LINQ objects in my LINQ data provider and returning an IQueryable to allow filtering etc. This works fine for filtering a simple object by it's ID or other property, but I am having a problem with a join table object that is composed of other child objects //CoreDBDataContext db = coreDB; public IQueryable<DTO.Position> GetPositions() { return from p in coreDB.Positions select new DTO.Position { DTO.User = new DTO.User(p.User.id,p.User