[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

LINQ to SQL - tables with foreign keys

Posted on 2013-05-16
3
Medium Priority
?
723 Views
Last Modified: 2013-06-04
Hello Experts,
I am having issue with writing LINQ to SQL query:

I use Entity Framework to generate Entities and try to write LINQ to extract data...

Tables:
OrderHeader  (OrderHeaderId - primary key)
OrderPayment (OrderHeaderId - foreign Key)

When i generate entities...

In OrderPayment  - i am not seeing OrderHeaderId (get set)...since they are keyed that may be the reason i am not seeing this field.


how to join this both tables in LINQ...


Here is my LINQ:  ( it is not liking bolded line..)

 lstBatchSettleRequestInfo = (from oh in _edgePier1DataConnection.OrderHeaders
                                     join op in _edgePier1DataConnection.OrderPayments on  oh.OrderHeaderId = op.OrderHeaderId                                     join reg in _edgePier1DataConnection.DynamicFields on oh.DynamicRecordId equals reg.DynamicRecordId
                                     join trans in _edgePier1DataConnection.DynamicFields on oh.DynamicRecordId equals trans.DynamicRecordId
                                     where  op.PaymentStatusId == 1
                                            && oh.OrderTypeId != 3
                                            && (op.TransactionTypeId == 52 || op.TransactionTypeId == 53)
                                            && oh.OrderHeaderId >= 9999999
                                            && reg.DynamicFieldLayoutId == 4 && reg.DynamicFieldValue != null
                                            && trans.DynamicFieldLayoutId == 5 && trans.DynamicFieldValue != null
                                     orderby oh.OrderHeaderId, op.CreateDate ascending
                                     select new BatchSettleRequestInfo
                                            {MerchantReferenceCode = oh.OrderHeaderId,
                                            PaymentCreateDate = op.CreateDate,
                                            PurchaseTotals_GrandTotalAmount = op.Amount,
                                            StoreID = oh.ReferenceField3,
                                            ccCaptureService_run = op.TransactionTypeId == 52 ? "true" : "",
                                            ccCaptureService_authRequestID = op.TransactionTypeId == 52 ? op.AuthTrnNo : "",
                                            ccCreditService_run = op.TransactionTypeId == 53 ? "true" : "",
                                            ccCreditService_captureRequestID = op.TransactionTypeId == 53 ? op.AuthTrnNo : ""
                                            }).Distinct().ToList();




any idea?

Thanks
0
Comment
Question by:mani_sai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 2000 total points
ID: 39172034
try this change

join op in _edgePier1DataConnection.OrderPayments on  oh.OrderHeaderId equals op.OrderHeaderId   ...

AW
0
 
LVL 8

Author Closing Comment

by:mani_sai
ID: 39219622
Thanks
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 39219759
Glad to be of assistance
AW
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question