This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I need to connect to existing tables in the Dynamics GP database and am having trouble with how the Entity is generated. The two tables I am trying to use in a model are POP10100 (PO Header) and POP10110 (PO Lines). There is a 1 to many relationship between the tables and I would like to use the Entity Model and LINQ to get the required data. The entire solution will be an EDI flat-file generator so I have another table where I will create a record for each PO that is sent to a partner. Ideally I would like to join that table as with the other 2 to determine which PO's need to be sent. My primary issue is because the PONUMBER field which exists in both tables is the primary key (POP10100) or part of a composite key (POP10110) but not visible in the Entity for me to use in a LINQ statement to join. I have attached the DDL for the 2 tables as well as the model files. I have installed the nightly build from 10/28/2010. Sorry about the newbie questions but it is so much easier when designing from the model and this has thrown me off. |
|
|
When you create an association in the designer, it generates three things: an entity collection on one side, and an entity reference and foreign key field on the other. For example, in your POLine entity, it will generate a POHeader entity reference and a POHeaderId foreign key. If I understand correctly, your problem is that you don't want a separate foreign key: you want the association to use the Id.PONumber as the foreign key. To do this, you need to select the association arrow, go to the Properties window, and set the Key Property Reference to Id.PONumber. This will prevent the designer from generating the POHeaderId field, and instead emit code that tells the association to use the PONumber field as the foreign key. Alternatively, if you don't need an association but just want to be able to write LINQ queries that involve PONumber, then in POHeader you can refer to it as Id, and in POLine as Id.PONumber: from h in uow.POHeaders where h.Id == "PO12987" select h; |
|