Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> Derived Models CreatePkPredicate only includes one primary key when the entity has more
 

Pages: 1
Bugs & Issues
Derived Models CreatePkPredicate only includes one primary key when the entity has more
Page:1/1 

  Print all messages in this thread  
Poster Message
TomDog
User



Location:
Wellington, New Zealand
Joined on:
25-Oct-2005 22:21:17
Posted:
570 posts
# Posted on: 25-Jan-2018 04:19:31.  
I created a Derived Model of northwind OrderDetail and in OrderDetailPersistence the CreatePkPredicate methods only used OrderId and not ProductId as well e.g
Code:
        /// <summary>Creates a primary key predicate to be used in a Where() clause in a Linq query which is executed on the database to fetch the original entity instance
        /// the specified <see cref="dto"/> object was projected from.</summary>
        /// <param name="dto">The dto object for which the primary key predicate has to be created for.</param>
        /// <returns>ready to use expression</returns>
        public static System.Linq.Expressions.Expression<Func<Northwind.DAL.EntityClasses.OrderDetailEntity, bool>> CreatePkPredicate(Dm.DtoClasses.OrderDetail dto)
        {
            return p__0 => p__0.OrderId == dto.OrderId;
        }

        /// <summary>Creates a primary key predicate to be used in a Where() clause in a Linq query which is executed on the database to fetch the original entity instances
        /// the specified set of <see cref="dtos"/> objects was projected from.</summary>
        /// <param name="dtos">The dto objects for which the primary key predicate has to be created for.</param>
        /// <returns>ready to use expression</returns>
        public static System.Linq.Expressions.Expression<Func<Northwind.DAL.EntityClasses.OrderDetailEntity, bool>> CreatePkPredicate(IEnumerable<Dm.DtoClasses.OrderDetail> dtos)
        {
            var ids = dtos.Select(p__1=>p__1.OrderId).ToList();
            return p__0 => ids.Contains(p__0.OrderId);
        }

        /// <summary>Creates a primary key predicate to be used in a Where() clause in a Linq query on an IEnumerable in-memory set of entity instances
        /// to retrieve the original entity instance the specified <see cref="dto"/> object was projected from.</summary>
        /// <param name="dto">The dto object for which the primary key predicate has to be created for.</param>
        /// <returns>ready to use func</returns>
        public static Func<Northwind.DAL.EntityClasses.OrderDetailEntity, bool> CreateInMemoryPkPredicate(Dm.DtoClasses.OrderDetail dto)
        {
            return p__0 => p__0.OrderId == dto.OrderId;
        }
Happens with all compound PK's I've seen.

Version 5.3.3 and 5.2
Jeremy Thomas
VS 2017 C#, LLBLGen v5.4, Winforms, WPF and ASP.NET MVCLLBL & LinqPad
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 25-Jan-2018 11:56:38.  
True. This is a limitation as a derived element has just 1 ID field. It picks the first one and ignores the rest. (as documents in a DocDB for instance don't have compound PKs either).

That said, for this particular method, it could perhaps be fixed if the template would check whether all fields in the PK of the entity type are in the derived element and if so, add them to the comparison.

(edit) the change will not be made to v5.3 but to v5.4 at the soonest, as it's a breaking change.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.