<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>MicrosoftNLayerApp Discussions Rss Feed</title><link>http://microsoftnlayerapp.codeplex.com/Thread/List.aspx</link><description>MicrosoftNLayerApp Discussions Rss Description</description><item><title>New Post: ¿Cómo compartir el mismo UnitOfWork por diferentes Repositorios?</title><link>https://microsoftnlayerapp.codeplex.com/discussions/447204</link><description>&lt;div style="line-height: normal;"&gt;Gracias Cesar!!!!&lt;br /&gt;
&lt;/div&gt;</description><author>allanob</author><pubDate>Tue, 18 Jun 2013 17:53:11 GMT</pubDate><guid isPermaLink="false">New Post: ¿Cómo compartir el mismo UnitOfWork por diferentes Repositorios? 20130618055311P</guid></item><item><title>New Post: ¿Cómo compartir el mismo UnitOfWork por diferentes Repositorios?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/447204</link><description>&lt;div style="line-height: normal;"&gt;Que &amp;quot;Object Lifetime Mananger&amp;quot; de UNITY estas utilizando para la resolucion de tu UnitOfWork (EF DbContext)?&lt;br /&gt;
Si utilizas &amp;quot;PerResolveLifetimeManager&amp;quot; para la resolucion del UnitOfWork (EF DbContext), ese objeto sera compartido por todos los objetos del mismo grafo de resolucion de UNITY, lo que significa que sea compartido por los diferentes Repositories que estes utilizando dentro del mismo grafo de objetos resueltos en UNITY.&lt;br /&gt;
&lt;br /&gt;
Sin embargo, al margen de que con ese lifetime manager lo puedes resolver..., cuestionate lo siguiente. Si tu problema de utilizar varios Repositories dentro del mismo Service no es por razones de consistencia de datos en consultas, sino porque quieres hacer una misma transaccion/actualizacion contra diferentes entidades, entonces, siguiendo los patrones de DDD, si tu transaccion engloba tres entidades diferentes (ej.: User, Membership y Profile), en ese Domain-Model contreto, probablemente esas tres entidades deberian formar parte de un mismo AGGREGATE: La forma de delimitar cuales son tus AGGREGATES debe de basarse precisamente en la consistencia requerida entre diferentes entidades y por ende, debes definir tus AGGREGATES basandote en las transacciones requeridas en cada domain-modelo concreto.&lt;br /&gt;
Por lo tanto, si tu AGGREGATE engloba esas tres entidades, y puesto que deberias tener un unico REPOSITORY por AGGREGATE (relacion 1:1 entre cada AGGREGATE-ROOT y REPOSITORY) que se preocupe por la consistencia de dichos objetos, entonces normalmente deberias de utilizar un unico Repository en cada transaccion, y  ahi no tendrias ese problema tampoco de compartir un UnitOfWork (DbContext) entre varios Repositories. Puedes hacer excepciones, pero lo normal en DDD Domain-Models deberia ser eso.&lt;br /&gt;
&lt;br /&gt;
No definas tus entidades y repositories up-front (directamente), piensa en las necesidades de cada domain-model concreto de cada BOUNDED-CONTEXT. Cada domain-Model de cada BC puede tener diferentes requerimientos de consistencia y por lo tanto, diferentes AGGREGATES y AGGREGATE-ROOTS. &lt;br /&gt;
&lt;/div&gt;</description><author>cesardl</author><pubDate>Sun, 16 Jun 2013 18:32:12 GMT</pubDate><guid isPermaLink="false">New Post: ¿Cómo compartir el mismo UnitOfWork por diferentes Repositorios? 20130616063212P</guid></item><item><title>New Post: ¿Cómo compartir el mismo UnitOfWork por diferentes Repositorios?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/447204</link><description>&lt;div style="line-height: normal;"&gt;Hola Microsoft España,&lt;br /&gt;
&lt;br /&gt;
Tengo un pequeño problema. Desde un servicio de la aplicación, que toma más de un IRepository, por ejemplo IUserRepository, IMembershipRepository, IprofileRepository etc. Despues crear un nuevo conjunto de datos, los tres repositorios deberían compartir el mismo UnitOfWork, para poder guardar los datos con un sólo UnitOfWork.Commit.&lt;br /&gt;
&lt;br /&gt;
El constructor del servicio es el estándar para IoC y DI:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;IUserRepository _userRepository;
IMembershipRepository _membershipRepository;
IProfileRepository _profileRepository;

AccountAppService(IUserRepository userRepository,
                                IMembershipRepository membershipRepository.
                                IProfileRepository _profileRepository)
{
    _userRepository = userRepository;
    _membershipRepository = membershipRepository;
    _profileRepository = profileRepository;
}&lt;/code&gt;&lt;/pre&gt;

¿Cómo podemos establecer el mismo UnitOfWork para los tres repositorios?&lt;br /&gt;
&lt;br /&gt;
Muchas Gracias,&lt;br /&gt;
Antonio&lt;br /&gt;
&lt;/div&gt;</description><author>allanob</author><pubDate>Sun, 16 Jun 2013 15:50:02 GMT</pubDate><guid isPermaLink="false">New Post: ¿Cómo compartir el mismo UnitOfWork por diferentes Repositorios? 20130616035002P</guid></item><item><title>New Post: Generic Repository Inheritance</title><link>http://microsoftnlayerapp.codeplex.com/discussions/445778</link><description>&lt;div style="line-height: normal;"&gt;Maybe it's not a good idea that specific repositories inherits from generic repository. &lt;br /&gt;
&lt;br /&gt;
What if an aggregate root shouldn't be removed by domain rules? Specific repository must override Remove method and trhow NotAllowedException.&lt;br /&gt;
&lt;br /&gt;
I don't like it. Specific repositories shouldn't expose unnecessary methods.&lt;br /&gt;
&lt;br /&gt;
I think a best aproach is inject the generic repository  in specific repository and use it internally.&lt;br /&gt;
Specific repository expose its own interface.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt; public class BankAccountRepository: IBankAccountRepository
    {
       
        private IRepository&amp;lt;BankAccount&amp;gt; _genericRepository; 
        public BankAccountRepository(IRepository&amp;lt;BankAccount&amp;gt; genericRepository)
        {
            _genericRepository = genericRepoisitory;
        }

        public void Add( BankAccount item)
        {
             _genericRepository.Add(item);       
         }

         //Don't expose Remove method!!!
        //public void Remove(BankAccount item){}
            
    } &lt;/code&gt;&lt;/pre&gt;

Generic repository and unit of work in generic repository can be injected by Unity using proper life cycle manager. Generic repository must expose unit of work to specific repository.&lt;br /&gt;
&lt;/div&gt;</description><author>jlvaquero</author><pubDate>Mon, 03 Jun 2013 07:21:42 GMT</pubDate><guid isPermaLink="false">New Post: Generic Repository Inheritance 20130603072142A</guid></item><item><title>New Post: Load Child Collection &amp; Unit Test &amp; ObjectContext</title><link>http://microsoftnlayerapp.codeplex.com/discussions/445704</link><description>&lt;div style="line-height: normal;"&gt;Hello,&lt;br /&gt;
&lt;br /&gt;
I have been using this architecture for some time and its great, but there is something I think I am missing. Let me explain in more detail.&lt;br /&gt;
&lt;br /&gt;
What I want to accomplish is just to load a filtered related collection of an entity. If I do it as this post suggest &lt;a href="http://msdn.microsoft.com/en-us/data/jj574232.aspx" rel="nofollow"&gt;http://msdn.microsoft.com/en-us/data/jj574232.aspx&lt;/a&gt; then my guess is like the number of queries could be even a performance issue.&lt;br /&gt;
&lt;br /&gt;
The code in the repository will look like this&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;public IEnumerable&amp;lt;Trabajador&amp;gt; GetForEstimacionCoste(DateTime fecha)
        {
            var etts = UnitOfWork.CreateSet&amp;lt;TrabajadorETT&amp;gt;()
                .Include(t =&amp;gt; t.Empresa.Tarifas)                
                .ToList();

            foreach (var item in etts)
            {
                ((DbContext)UnitOfWork)
                    .Entry(item).Collection(t =&amp;gt; t.Contrataciones).Query()
                    .Where(c =&amp;gt; c.FechaInicio.Month == fecha.Month)
                    .Load();
            }

            var company = UnitOfWork.CreateSet&amp;lt;TrabajadorEmpresa&amp;gt;()
                .Include(t =&amp;gt; t.Convenio.PlusesActividad)                  
                .Include(t =&amp;gt; t.CostesDivision)                
                .ToList();

            var all = etts.Union&amp;lt;Trabajador&amp;gt;(company).ToList();

            foreach (var item in all)
            {
                ((DbContext)UnitOfWork)
                    .Entry(item).Collection(t =&amp;gt; t.Imputaciones).Query()
                    .Where(c =&amp;gt; c.Fecha.Month == fecha.Month)
                    .Load();
            }

            return all;
        }&lt;/code&gt;&lt;/pre&gt;

The code uses some Spanish words, sorry for that. And yes, that's a totally different discussion :)&lt;br /&gt;
&lt;br /&gt;
So the test for the previous method in the repository will be something like...&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;[TestMethod]
        public void GetTrabajadoresForEstimacionCosteRepositoryTest()
        {
            var context = new WorkContext();
            var trabajadorRepository = new TrabajadorRepository(context);
            var fecha = new DateTime(2013, 06, 30);
            var resultado = trabajadorRepository.GetForEstimacionCoste(fecha);

            var etts = resultado.OfType&amp;lt;TrabajadorETT&amp;gt;();
            Assert.IsNotNull(etts.ElementAt(0).Contrataciones);
            Assert.AreEqual(1, etts.ElementAt(0).Contrataciones.Count);

            Assert.AreEqual(3, resultado.Count());

            Assert.AreEqual(3, resultado.SelectMany(t =&amp;gt; t.Imputaciones).Count());
        }&lt;/code&gt;&lt;/pre&gt;

And it is working. And it seems like fine, more or less. But as mentioned at the beginning I think there is a better way of doing it. Using the entity fixup of EF5. So that would mean loading all the related collections and then when querying the employees I will have the filtered collection just as I wanted to accomplish.&lt;br /&gt;
&lt;br /&gt;
That would be something like...&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;public IEnumerable&amp;lt;Trabajador&amp;gt; GetForEstimacionCoste(DateTime fecha)
        {
            UnitOfWork.CreateSet&amp;lt;Contratacion&amp;gt;().Where(c =&amp;gt; c.FechaInicio.Month == fecha.Month).Load();
            UnitOfWork.CreateSet&amp;lt;Imputacion&amp;gt;().Where(i =&amp;gt; i.Fecha.Month == fecha.Month).Load();

            var etts = UnitOfWork.CreateSet&amp;lt;TrabajadorETT&amp;gt;()
                .Include(t =&amp;gt; t.Empresa.Tarifas)                
                .AsEnumerable();

            var company = UnitOfWork.CreateSet&amp;lt;TrabajadorEmpresa&amp;gt;()
                .Include(t =&amp;gt; t.Convenio.PlusesActividad)                  
                .Include(t =&amp;gt; t.CostesDivision)                
                .AsEnumerable();

            return etts.Union&amp;lt;Trabajador&amp;gt;(company).ToList();
        }&lt;/code&gt;&lt;/pre&gt;

Which works ok, but when trying to get the test passed I get an ObjectDisposedException: the ObjectContext instance has been disposed and can no longer... &lt;br /&gt;
&lt;br /&gt;
I guess the issue here is the same one I tried to explain in &lt;a href="http://stackoverflow.com/questions/16468252/count-method-in-repository-ef5" rel="nofollow"&gt;http://stackoverflow.com/questions/16468252/count-method-in-repository-ef5&lt;/a&gt; and my fear is the there is a concept I am missing. &lt;br /&gt;
&lt;br /&gt;
I would like to have an explanation of why this is happening, why I can only reproduces with Unit Tests and which of the two options is the best approach for this kind of situations.&lt;br /&gt;
&lt;br /&gt;
As the post is long enough I hide some details like the entities and so, whatever info you consider it relevant just let me know. &lt;br /&gt;
&lt;br /&gt;
Thanks a lot in advance for your help.&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
&lt;/div&gt;</description><author>descalada</author><pubDate>Sun, 02 Jun 2013 07:11:05 GMT</pubDate><guid isPermaLink="false">New Post: Load Child Collection &amp; Unit Test &amp; ObjectContext 20130602071105A</guid></item><item><title>New Post: Is it wise to abstract the entities?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443956</link><description>&lt;div style="line-height: normal;"&gt;Some key concepts that conform Dynamics CRM as an xRM, a valid solution from LA Council to a little retail shop, able to grow, scale and extend:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;
Metadata. That means that a &amp;quot;Contact&amp;quot; entity can be freely changed to whatever you want, for example, in one of my projects &amp;quot;Contact&amp;quot; (a person) was changed to &amp;quot;RFID Tag&amp;quot; (a vehicle) with very different properties. There's no &amp;quot;Contacts&amp;quot; table in database: there is a table &amp;quot;able to use&amp;quot; certain entities with some relationships, properties, forms, etc. Metadata shows you a &amp;quot;Contact&amp;quot; or a &amp;quot;RFID Tag&amp;quot; or any other concept, but the entity data stored in the database... is always the same. Metadata allows to adapt Dynamics CRM to any organitation, even if doesn't exist marketing or sales departament (Los Angeles Council). Anyway, Dynamics CRM database is transparent for developers and consultants. I never logged in the Dynamics CRM SQL Server database: this is the power of metadata-oriented database design.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
DDD design. I don't know if all Dynamics CRM 2011 is a 100% DDD software, but for sure most part of Dynamics CRM follows this design patterns. For example, you can obtain all entities map from your Dynamics CRM implementation in Visual Studio and work with this &amp;quot;near to POCO clases&amp;quot; and CRM &amp;quot;DBContext&amp;quot;, changing what you need. You can use Dynamics CRM elements like distributed software and independent layers and use WCF etc. For example, I've designed recently a complex BackOffice software that works with the Dynamics CRM entities etc separately, using Dynamics CRM almost &amp;quot;only&amp;quot; for UI and BI human interaction. Entity Framework Development Team uses the Dynamics Navision set of entities (similar to the CRM ones) for testing EF performance, isolated from the product. Scalability and extension capabilities of Dynamics CRM depends on this kind of design patterns.&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
What I'm trying to say is that Dynamics CRM is a xRM PLATFORM where developers can freely build a solid, flexible and scalable solutions. In complex situations Dynamics CRM becomes a &amp;quot;software development environment&amp;quot; while in most cases users can use &amp;quot;out-of-the-box&amp;quot; capabilities and build customizations themselves.&lt;br /&gt;
&lt;br /&gt;
From a platform perspective, its difficult to talk about Dynamics CRM &amp;quot;funtionalities&amp;quot;. The same happens if we talk about another platform: an aircraft carrier. Aircaft carriers can't fly.  Dynamics CRM is ready to connect to or integrate enterprise software thanks to the metadata and DDD design patterns. This Enterprise software are the planes.&lt;br /&gt;
&lt;br /&gt;
I think it's very difficult too - and expensive  - to build a platform like Dynamics CRM even with a good design, even following the cesardl team patterns. Perhaps to follow this patterns building a solution over Dynamics CRM can be a better aproach. I think that today, custom applications development and platforms like Dynamics CRM or SharePoint are strongly connected worlds, even usually they seems isolated one to each other.&lt;br /&gt;
&lt;br /&gt;
Por cierto César, vuestro trabajo es uno de mis libros de cabecera. Muchas gracias.&lt;br /&gt;
&lt;/div&gt;</description><author>JuanPabloRguez</author><pubDate>Sun, 26 May 2013 12:05:24 GMT</pubDate><guid isPermaLink="false">New Post: Is it wise to abstract the entities? 20130526120524P</guid></item><item><title>New Post: Development of Microsoft Spain</title><link>http://microsoftnlayerapp.codeplex.com/discussions/436183</link><description>&lt;div style="line-height: normal;"&gt;
&lt;div&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;Could be! &lt;/span&gt;&lt;span style="font-size:11.0pt; font-family:Wingdings; color:#1F497D"&gt;J&lt;/span&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;Send me an email (to cesardl at microsoft.com) so we plan offline, ok?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;There are quite a few things we could do..
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;Cheers,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;Cesar.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a name="_MailEndCompose"&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in"&gt;
&lt;p&gt;&lt;b&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><author>cesardl</author><pubDate>Tue, 21 May 2013 23:50:06 GMT</pubDate><guid isPermaLink="false">New Post: Development of Microsoft Spain 20130521115006P</guid></item><item><title>New Post: Development of Microsoft Spain</title><link>http://microsoftnlayerapp.codeplex.com/discussions/436183</link><description>&lt;div style="line-height: normal;"&gt;Cesar,&lt;br /&gt;
&lt;br /&gt;
Would you like any help on getting this Project going forward? I really would like to help so submit patches or anything else I can do to keep this Project going...&lt;br /&gt;
&lt;br /&gt;
Bruno&lt;br /&gt;
&lt;/div&gt;</description><author>brunobertechini</author><pubDate>Tue, 21 May 2013 22:33:43 GMT</pubDate><guid isPermaLink="false">New Post: Development of Microsoft Spain 20130521103343P</guid></item><item><title>New Post: Is it wise to abstract the entities?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443956</link><description>&lt;div style="line-height: normal;"&gt;Nice to hear that :)&lt;br /&gt;
&lt;br /&gt;
Cesar, if you could have a look at these thread, I will appreciate:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://microsoftnlayerapp.codeplex.com/discussions/444470" rel="nofollow"&gt;Infrastructure.Logging - EventSource&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://microsoftnlayerapp.codeplex.com/discussions/264445#post1044113" rel="nofollow"&gt;WCF Error Handler&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
&lt;br /&gt;
Bruno&lt;br /&gt;
&lt;/div&gt;</description><author>brunobertechini</author><pubDate>Tue, 21 May 2013 21:08:19 GMT</pubDate><guid isPermaLink="false">New Post: Is it wise to abstract the entities? 20130521090819P</guid></item><item><title>New Post: WCF &amp; Exception Handling Improvements for V2.0</title><link>http://microsoftnlayerapp.codeplex.com/discussions/264445</link><description>&lt;div style="line-height: normal;"&gt;I figured out by myself:&lt;br /&gt;
&lt;br /&gt;
I have changed the code from :&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;ApplicationErrorHandler.ProvideFault&lt;/strong&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;//create service error
ApplicationServiceError defaultError = new ApplicationServiceError()
{
   ErrorMessage = Messages.message_DefaultErrorMessage,
};&lt;/code&gt;&lt;/pre&gt;

&lt;strong&gt;To:&lt;/strong&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;//create service error
ApplicationServiceError defaultError = new ApplicationServiceError()
{
   ErrorMessage = error.Message // Modified to include the exception raised
};&lt;/code&gt;&lt;/pre&gt;

I have changed this so my custom exception type (DomainException) get forwarded to the client. (Of course I am forwarding only known exception - my custom type)&lt;br /&gt;
&lt;br /&gt;
At the client:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;try
{
     // Call proxy.Action
}
catch (FaultException&amp;lt;ServiceError&amp;gt; ex)
{
   properties.Status = SPEventReceiverStatus.CancelWithError;
   properties.ErrorMessage = ex.Detail.ErrorMessage;
}&lt;/code&gt;&lt;/pre&gt;

Thank you very much!&lt;br /&gt;
&lt;br /&gt;
Bruno&lt;br /&gt;
&lt;/div&gt;</description><author>brunobertechini</author><pubDate>Tue, 21 May 2013 21:07:15 GMT</pubDate><guid isPermaLink="false">New Post: WCF &amp; Exception Handling Improvements for V2.0 20130521090715P</guid></item><item><title>New Post: Is it wise to abstract the entities?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443956</link><description>&lt;div style="line-height: normal;"&gt;
&lt;div&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;Thanks a lot for the feedback Bruno!
&lt;/span&gt;&lt;span style="font-size:11.0pt; font-family:Wingdings; color:#1F497D"&gt;J&lt;/span&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;I agree with your comments, of course.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="ES" style="font-size:11.0pt; font-family:"&gt;Cesar de la Torre.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="ES" style="font-size:11.0pt; font-family:"&gt;Microsoft Corp&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a name="_MailEndCompose"&gt;&lt;span lang="ES" style="font-size:11.0pt; font-family:"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in"&gt;
&lt;p&gt;&lt;b&gt;&lt;span style="font-size:11.0pt; font-family:"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><author>cesardl</author><pubDate>Tue, 21 May 2013 19:42:16 GMT</pubDate><guid isPermaLink="false">New Post: Is it wise to abstract the entities? 20130521074216P</guid></item><item><title>New Post: Buenas prácticas</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443899</link><description>&lt;div style="line-height: normal;"&gt;Well,&lt;br /&gt;
&lt;br /&gt;
I have to tell you the &amp;quot;inconvenient&amp;quot; is a word that leads me to &amp;quot;maintenance problems in the feature&amp;quot; in your case.&lt;br /&gt;
&lt;br /&gt;
I mean, every time you need something different on your View, you have to change your domain behavior. Is that correct?&lt;br /&gt;
&lt;br /&gt;
Every time you need diferente business logic that may change properties of na existing entity, you would have to change every view that uses it.&lt;br /&gt;
&lt;br /&gt;
Again: DTOs are not &amp;quot;for convenience&amp;quot; only. If you use them correctly and also create a Service Layer Approach you would benefit of separation of concerns.&lt;br /&gt;
&lt;br /&gt;
I know its hard to build things &amp;quot;right&amp;quot;. But thats the price to pay for a good system.&lt;br /&gt;
&lt;br /&gt;
You can do it step-by-step. A very good approach is: REfactor your code as you have new features. Like: Every time you &amp;quot;touch&amp;quot; one class, refactor it to use DTOs. And when you realize, everything would be using it. So you can start phase 2 and create na intermediate layer like na AppService (from DDD).&lt;br /&gt;
&lt;br /&gt;
I think you are not doing DDD right on App Layer. The App layer should be a mediation between Presentation (user) and the domain layer. You have the domain layer right on presentation.&lt;br /&gt;
&lt;br /&gt;
If you want to have the benefits of DDD, my advice is to refactor your code slowly...but create a goal and work for it :)&lt;br /&gt;
&lt;br /&gt;
Any help you need let me know&lt;br /&gt;
&lt;br /&gt;
Bruno&lt;br /&gt;
&lt;/div&gt;</description><author>brunobertechini</author><pubDate>Tue, 21 May 2013 19:10:25 GMT</pubDate><guid isPermaLink="false">New Post: Buenas prácticas 20130521071025P</guid></item><item><title>New Post: Is it wise to abstract the entities?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443956</link><description>&lt;div style="line-height: normal;"&gt;Hi Alex,&lt;br /&gt;
&lt;br /&gt;
Sorry for the delay, but I am on a busy month (as Always) :)&lt;br /&gt;
&lt;br /&gt;
My suggestion for you is: &lt;strong&gt;Embrace DDD and NLayerAppV2 as much as you can&lt;/strong&gt;. &lt;br /&gt;
It will help you a lot if your system is intended to have a very long lifecycle and will stay there for a while.&lt;br /&gt;
&lt;br /&gt;
I am working on a system I can call it medium/big and the advantages are so huge I cant think how I could work without these Technologies and approaches.&lt;br /&gt;
&lt;br /&gt;
I am still on a learning courve, but I think I have solid practical implementations of NLayerAppv2-like Project by now. I am not using CQRS yet (still to come in next months). I am using Sharepoint 2013 to behave as my &amp;quot;Message Bus&amp;quot; and also for Presentation and sometimes App layer.&lt;br /&gt;
&lt;br /&gt;
The thread you mentioned above was initiated by me a while ago. I was discussing with Cesar regarding basic methodology to get the hands on Bounded Contexts, Modules and others DDD terms in practical.&lt;br /&gt;
&lt;br /&gt;
I will be very gratefull if I can help you guys in anything you need to design or code your app. I can do my best to provide you my suggestions and experiences :)&lt;br /&gt;
&lt;br /&gt;
Again: I would definitely go for DDD and services-aware approach for a big solution as you are intended to build.&lt;br /&gt;
Regardless if current products do it or not. They may have tons of reasons to build the way they do: time, legacy versions, compatibility, lack of DDD maturity at the time of development, and many others.&lt;br /&gt;
&lt;br /&gt;
So my final word is : Go for DDD, period. Talk to your business, define your entities/modules/bounded contexto and use NLayerAppV2 as a tech guide. Im sure you'll be happy in the future.&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
&lt;br /&gt;
Bruno&lt;br /&gt;
&lt;br /&gt;
P.S.: Feel free to share anything else or popup any other doubts/questions.&lt;br /&gt;
&lt;/div&gt;</description><author>brunobertechini</author><pubDate>Tue, 21 May 2013 19:02:45 GMT</pubDate><guid isPermaLink="false">New Post: Is it wise to abstract the entities? 20130521070245P</guid></item><item><title>New Post: Infrastructure.Logging - Event Source</title><link>http://microsoftnlayerapp.codeplex.com/discussions/444470</link><description>&lt;div style="line-height: normal;"&gt;Hi Cesar,&lt;br /&gt;
&lt;br /&gt;
By now, I have almost 95% of my Project implemented according to NLayerAppV2.&lt;br /&gt;
&lt;br /&gt;
Have to say: Its wonderfull. It really helps. Thanks a lot. And congratulations for the good work so far.&lt;br /&gt;
&lt;br /&gt;
I have one question regarding ILogger:&lt;br /&gt;
&lt;br /&gt;
Would you think its a good idea to create a method at ILogger interface to set the source string for a event log ? That would help a lot.&lt;br /&gt;
&lt;br /&gt;
Like SetSource(string sourceName) so  we can use it for eventlogs (Windows) , filenames (Text) and so on.&lt;br /&gt;
&lt;br /&gt;
Would like to know your thoughts about it.&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
&lt;br /&gt;
Bruno&lt;br /&gt;
&lt;/div&gt;</description><author>brunobertechini</author><pubDate>Tue, 21 May 2013 18:50:23 GMT</pubDate><guid isPermaLink="false">New Post: Infrastructure.Logging - Event Source 20130521065023P</guid></item><item><title>New Post: Is it wise to abstract the entities?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443956</link><description>&lt;div style="line-height: normal;"&gt;Hi Bruno,&lt;br /&gt;
&lt;br /&gt;
No. We are not going to build on top of any CRM. I wanted to give an example to clarify the type of our application. So, it would be a completely separated application with almost the same functionalities as most CRM applications.&lt;br /&gt;
&lt;br /&gt;
Alex&lt;br /&gt;
&lt;/div&gt;</description><author>Cyberdude3</author><pubDate>Fri, 17 May 2013 09:14:38 GMT</pubDate><guid isPermaLink="false">New Post: Is it wise to abstract the entities? 20130517091438A</guid></item><item><title>New Post: Is it wise to abstract the entities?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443956</link><description>&lt;div style="line-height: normal;"&gt;Hi Alex,&lt;br /&gt;
&lt;br /&gt;
Are you going to build your App on top of Microsoft CRM or would it be a completely separated app?&lt;br /&gt;
&lt;br /&gt;
Bruno&lt;br /&gt;
&lt;/div&gt;</description><author>brunobertechini</author><pubDate>Fri, 17 May 2013 00:59:46 GMT</pubDate><guid isPermaLink="false">New Post: Is it wise to abstract the entities? 20130517125946A</guid></item><item><title>New Post: Is it wise to abstract the entities?</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443956</link><description>&lt;div style="line-height: normal;"&gt;Hi,&lt;br /&gt;
We want to build an enterprise application which does have many CRM functionalities. And we are stuck with a very important architectural decision. When we look at Microsoft CRM 2011 we see that all entities are in the database. It looks like that there is a huge abstraction layer similar to CMS has been build and used to build the application. As the result without using SDK, a programmer should write code like dynamic[&amp;quot;Account&amp;quot;] to get the customer instead of just write Account acc = new Account().&lt;br /&gt;
Well, we don't want to rebuild the MS CRM, we just want to know is it wise to build an application which &lt;br /&gt;
1- has multiple different UI and services (mobile app, windows service, asp.net mvc web)&lt;br /&gt;
2- has accounts, products, orders, bills, discount and that kind of entities&lt;br /&gt;
3- and the products has many different attributes and dependencies on each other&lt;br /&gt;
&lt;br /&gt;
with an CMS?&lt;br /&gt;
Because to me, a CMS makes entities abstract by defining each as a as content. So you could see all entities in the some database table of the CMS. Just like most CRM's have.&lt;br /&gt;
&lt;br /&gt;
Or we could use an architecture like this great example of Domain Oriented N-Layered sample application. When we do that, we will use entlib 6.0 and Unity 3.0 as well and build WebApi's for all type of client app's.&lt;br /&gt;
&lt;br /&gt;
I know that without the knowlegde over the domain nobody can make such decision or advice. But see it as a CRM application.&lt;br /&gt;
By the way this post &lt;a href="https://microsoftnlayerapp.codeplex.com/discussions/431320" rel="nofollow"&gt;https://microsoftnlayerapp.codeplex.com/discussions/431320&lt;/a&gt; was also help for us. But didn't make the decision any easier :-)&lt;br /&gt;
&lt;br /&gt;
Any help would be greatly appreciated.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Alex&lt;br /&gt;
&lt;/div&gt;</description><author>Cyberdude3</author><pubDate>Thu, 16 May 2013 19:08:25 GMT</pubDate><guid isPermaLink="false">New Post: Is it wise to abstract the entities? 20130516070825P</guid></item><item><title>New Post: Buenas prácticas</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443899</link><description>&lt;div style="line-height: normal;"&gt;Hello!&lt;br /&gt;
I understand you now! :)&lt;br /&gt;
Yes, this is a inconvenient but this is not compensable work involved in creating DTO project where there are many entities (97 in this and 192 on the other we have with DDD). Is there any way of linking OFF, automatically create them, etc. ..?&lt;br /&gt;
&lt;br /&gt;
Thanks for all!! :) it's a great conversation with u :)&lt;br /&gt;
&lt;/div&gt;</description><author>fjaumot</author><pubDate>Thu, 16 May 2013 18:41:41 GMT</pubDate><guid isPermaLink="false">New Post: Buenas prácticas 20130516064141P</guid></item><item><title>New Post: Buenas prácticas</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443899</link><description>&lt;div style="line-height: normal;"&gt;&lt;strong&gt;fjaumot wrote:&lt;/strong&gt;&lt;br /&gt;
&lt;blockquote&gt;
Hello Bruno, !&lt;br /&gt;
Beacuse I need the DTO? I dosen't understand this.&lt;br /&gt;
I have,&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;
UX (mvc)&lt;br /&gt;
Project.BackOffice (ViewModel, Controller, Js, View...)&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
Application&lt;br /&gt;
Project.Application (use repositories and entities)&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
Domain&lt;br /&gt;
Project.Domani.Entities (Created by t4 and used in Application and UX)&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
Data&lt;br /&gt;
Project.Data (EDMX, Context (t4) with UnitOfWork and Repositories)&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;
I dosen't understand because I need to use DTO... Because I dosen't use POCO Entities??&lt;br /&gt;
&lt;br /&gt;
Thank you!!&lt;br /&gt;
&lt;/blockquote&gt;
Because, in my opinion, you should never use Domain Entities outside the domain and Application Layers.&lt;br /&gt;
&lt;br /&gt;
Simple example: If you have &amp;quot;full rich entities&amp;quot;  right at the controller, why do you have Application layer? &lt;br /&gt;
&lt;br /&gt;
For example, lets say the Invoice entity has a &amp;quot;Process&amp;quot; method. And youre suppose to handle it using na AppService right? like you did InvoiceManagementService.&lt;br /&gt;
&lt;br /&gt;
Regardless the existence of this InvoiceManagementService, right on controller you can do something like:&lt;br /&gt;
&lt;br /&gt;
invoice.Process() --&amp;gt; And this would break something in your domain since youre not using your Application logic from InvoiceManagementService.&lt;br /&gt;
&lt;br /&gt;
Business logic should never leave domain boundaries.&lt;br /&gt;
&lt;br /&gt;
I try to use a mix of DDD and Union Architecture for better maintenance:&lt;br /&gt;
&lt;a href="http://jeffreypalermo.com/blog/the-onion-architecture-part-1/" rel="nofollow"&gt;http://jeffreypalermo.com/blog/the-onion-architecture-part-1/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Bruno&lt;br /&gt;
&lt;/div&gt;</description><author>brunobertechini</author><pubDate>Thu, 16 May 2013 17:01:29 GMT</pubDate><guid isPermaLink="false">New Post: Buenas prácticas 20130516050129P</guid></item><item><title>New Post: Buenas prácticas</title><link>http://microsoftnlayerapp.codeplex.com/discussions/443899</link><description>&lt;div style="line-height: normal;"&gt;Hello Bruno, !&lt;br /&gt;
Beacuse I need the DTO? I dosen't understand this.&lt;br /&gt;
I have,&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;
UX (mvc)&lt;br /&gt;
Project.BackOffice (ViewModel, Controller, Js, View...)&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
Application&lt;br /&gt;
Project.Application (use repositories and entities)&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
Domain&lt;br /&gt;
Project.Domani.Entities (Created by t4 and used in Application and UX)&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
Data&lt;br /&gt;
Project.Data (EDMX, Context (t4) with UnitOfWork and Repositories)&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;
I dosen't understand because I need to use DTO... Because I dosen't use POCO Entities??&lt;br /&gt;
&lt;br /&gt;
Thank you!!&lt;br /&gt;
&lt;/div&gt;</description><author>fjaumot</author><pubDate>Thu, 16 May 2013 16:47:53 GMT</pubDate><guid isPermaLink="false">New Post: Buenas prácticas 20130516044753P</guid></item></channel></rss>