How to Join two columns from table A with two columns from table B - Linq join MVC












0














How can i Join two columns from dbo.Sales Invoice Line with two columns from dbo.Value Entry in linq SQL! Can anyone please help me :) thanks in advance :)



This is SQL version :



 SELECT  *
FROM dbo.[Item Ledger Entry]
INNER JOIN
dbo.[Value Entry] ON dbo.[Item Ledger Entry].[Entry No_] = dbo.[Value Entry].[Item Ledger Entry No_]

//Start here
INNER JOIN
dbo.[Sales Invoice Line] ON dbo.[Value Entry].[Document No_] = dbo.[Sales Invoice Line].[Document No_]
AND
dbo.[Value Entry].[Document Line No_] = dbo.[Sales Invoice Line].[Line No_]


And this is linq version i end up with , but im not sure i did it in the right way!:



from cbr in db.Contact_Business_Relation
join c in db.Contact on cbr.Contact_No_ equals c.Company_No_
join sa in db.Sales_Invoice_Header on cbr.No_ equals sa.Sell_to_Customer_No_
join sih in db.Sales_Invoice_Line on sa.No_ equals sih.Document_No_

//Start here
join ve in db.Value_Entry on sih.Document_No_ equals ve.Document_No_
join vetwo in db.Value_Entry on sih.Line_No_ equals vetwo.Document_Line_No_
join item in db.Item_Ledger_Entry on ve.Item_Ledger_Entry_No_ equals item.Entry_No_









share|improve this question
























  • //Start here, but its not working How is it not working?
    – mjwills
    Nov 13 '18 at 9:42












  • @mjwills it cant execute the query and page still wating /loading for long time
    – The First
    Nov 13 '18 at 9:49












  • @mjwills and i also not sure i did it in the right way !
    – The First
    Nov 13 '18 at 9:57










  • So why don't you share the relevant parts of your classes with us. Are you using entity framework?
    – Harald Coppoolse
    Nov 13 '18 at 10:03
















0














How can i Join two columns from dbo.Sales Invoice Line with two columns from dbo.Value Entry in linq SQL! Can anyone please help me :) thanks in advance :)



This is SQL version :



 SELECT  *
FROM dbo.[Item Ledger Entry]
INNER JOIN
dbo.[Value Entry] ON dbo.[Item Ledger Entry].[Entry No_] = dbo.[Value Entry].[Item Ledger Entry No_]

//Start here
INNER JOIN
dbo.[Sales Invoice Line] ON dbo.[Value Entry].[Document No_] = dbo.[Sales Invoice Line].[Document No_]
AND
dbo.[Value Entry].[Document Line No_] = dbo.[Sales Invoice Line].[Line No_]


And this is linq version i end up with , but im not sure i did it in the right way!:



from cbr in db.Contact_Business_Relation
join c in db.Contact on cbr.Contact_No_ equals c.Company_No_
join sa in db.Sales_Invoice_Header on cbr.No_ equals sa.Sell_to_Customer_No_
join sih in db.Sales_Invoice_Line on sa.No_ equals sih.Document_No_

//Start here
join ve in db.Value_Entry on sih.Document_No_ equals ve.Document_No_
join vetwo in db.Value_Entry on sih.Line_No_ equals vetwo.Document_Line_No_
join item in db.Item_Ledger_Entry on ve.Item_Ledger_Entry_No_ equals item.Entry_No_









share|improve this question
























  • //Start here, but its not working How is it not working?
    – mjwills
    Nov 13 '18 at 9:42












  • @mjwills it cant execute the query and page still wating /loading for long time
    – The First
    Nov 13 '18 at 9:49












  • @mjwills and i also not sure i did it in the right way !
    – The First
    Nov 13 '18 at 9:57










  • So why don't you share the relevant parts of your classes with us. Are you using entity framework?
    – Harald Coppoolse
    Nov 13 '18 at 10:03














0












0








0







How can i Join two columns from dbo.Sales Invoice Line with two columns from dbo.Value Entry in linq SQL! Can anyone please help me :) thanks in advance :)



This is SQL version :



 SELECT  *
FROM dbo.[Item Ledger Entry]
INNER JOIN
dbo.[Value Entry] ON dbo.[Item Ledger Entry].[Entry No_] = dbo.[Value Entry].[Item Ledger Entry No_]

//Start here
INNER JOIN
dbo.[Sales Invoice Line] ON dbo.[Value Entry].[Document No_] = dbo.[Sales Invoice Line].[Document No_]
AND
dbo.[Value Entry].[Document Line No_] = dbo.[Sales Invoice Line].[Line No_]


And this is linq version i end up with , but im not sure i did it in the right way!:



from cbr in db.Contact_Business_Relation
join c in db.Contact on cbr.Contact_No_ equals c.Company_No_
join sa in db.Sales_Invoice_Header on cbr.No_ equals sa.Sell_to_Customer_No_
join sih in db.Sales_Invoice_Line on sa.No_ equals sih.Document_No_

//Start here
join ve in db.Value_Entry on sih.Document_No_ equals ve.Document_No_
join vetwo in db.Value_Entry on sih.Line_No_ equals vetwo.Document_Line_No_
join item in db.Item_Ledger_Entry on ve.Item_Ledger_Entry_No_ equals item.Entry_No_









share|improve this question















How can i Join two columns from dbo.Sales Invoice Line with two columns from dbo.Value Entry in linq SQL! Can anyone please help me :) thanks in advance :)



This is SQL version :



 SELECT  *
FROM dbo.[Item Ledger Entry]
INNER JOIN
dbo.[Value Entry] ON dbo.[Item Ledger Entry].[Entry No_] = dbo.[Value Entry].[Item Ledger Entry No_]

//Start here
INNER JOIN
dbo.[Sales Invoice Line] ON dbo.[Value Entry].[Document No_] = dbo.[Sales Invoice Line].[Document No_]
AND
dbo.[Value Entry].[Document Line No_] = dbo.[Sales Invoice Line].[Line No_]


And this is linq version i end up with , but im not sure i did it in the right way!:



from cbr in db.Contact_Business_Relation
join c in db.Contact on cbr.Contact_No_ equals c.Company_No_
join sa in db.Sales_Invoice_Header on cbr.No_ equals sa.Sell_to_Customer_No_
join sih in db.Sales_Invoice_Line on sa.No_ equals sih.Document_No_

//Start here
join ve in db.Value_Entry on sih.Document_No_ equals ve.Document_No_
join vetwo in db.Value_Entry on sih.Line_No_ equals vetwo.Document_Line_No_
join item in db.Item_Ledger_Entry on ve.Item_Ledger_Entry_No_ equals item.Entry_No_






c# sql-server linq






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 9:56







The First

















asked Nov 13 '18 at 9:41









The FirstThe First

558




558












  • //Start here, but its not working How is it not working?
    – mjwills
    Nov 13 '18 at 9:42












  • @mjwills it cant execute the query and page still wating /loading for long time
    – The First
    Nov 13 '18 at 9:49












  • @mjwills and i also not sure i did it in the right way !
    – The First
    Nov 13 '18 at 9:57










  • So why don't you share the relevant parts of your classes with us. Are you using entity framework?
    – Harald Coppoolse
    Nov 13 '18 at 10:03


















  • //Start here, but its not working How is it not working?
    – mjwills
    Nov 13 '18 at 9:42












  • @mjwills it cant execute the query and page still wating /loading for long time
    – The First
    Nov 13 '18 at 9:49












  • @mjwills and i also not sure i did it in the right way !
    – The First
    Nov 13 '18 at 9:57










  • So why don't you share the relevant parts of your classes with us. Are you using entity framework?
    – Harald Coppoolse
    Nov 13 '18 at 10:03
















//Start here, but its not working How is it not working?
– mjwills
Nov 13 '18 at 9:42






//Start here, but its not working How is it not working?
– mjwills
Nov 13 '18 at 9:42














@mjwills it cant execute the query and page still wating /loading for long time
– The First
Nov 13 '18 at 9:49






@mjwills it cant execute the query and page still wating /loading for long time
– The First
Nov 13 '18 at 9:49














@mjwills and i also not sure i did it in the right way !
– The First
Nov 13 '18 at 9:57




@mjwills and i also not sure i did it in the right way !
– The First
Nov 13 '18 at 9:57












So why don't you share the relevant parts of your classes with us. Are you using entity framework?
– Harald Coppoolse
Nov 13 '18 at 10:03




So why don't you share the relevant parts of your classes with us. Are you using entity framework?
– Harald Coppoolse
Nov 13 '18 at 10:03












1 Answer
1






active

oldest

votes


















0














You can do this multi-condition join by matching an object on each side of the join condition. This can be a typed object, but an anonymous object is also fine, provided that the property names match. The relevant part of your query should look something like this:



//Start here
join ve in db.Value_Entry on new {
DocNo = sih.Document_No_,
LineNo = sih.Line_No_ } equals new {
DocNo = ve.Document_No_,
LineNo = ve.Document_Line_No_ }





share|improve this answer





















  • Thanks cf_en :)
    – The First
    Nov 13 '18 at 10:31











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278018%2fhow-to-join-two-columns-from-table-a-with-two-columns-from-table-b-linq-join-m%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You can do this multi-condition join by matching an object on each side of the join condition. This can be a typed object, but an anonymous object is also fine, provided that the property names match. The relevant part of your query should look something like this:



//Start here
join ve in db.Value_Entry on new {
DocNo = sih.Document_No_,
LineNo = sih.Line_No_ } equals new {
DocNo = ve.Document_No_,
LineNo = ve.Document_Line_No_ }





share|improve this answer





















  • Thanks cf_en :)
    – The First
    Nov 13 '18 at 10:31
















0














You can do this multi-condition join by matching an object on each side of the join condition. This can be a typed object, but an anonymous object is also fine, provided that the property names match. The relevant part of your query should look something like this:



//Start here
join ve in db.Value_Entry on new {
DocNo = sih.Document_No_,
LineNo = sih.Line_No_ } equals new {
DocNo = ve.Document_No_,
LineNo = ve.Document_Line_No_ }





share|improve this answer





















  • Thanks cf_en :)
    – The First
    Nov 13 '18 at 10:31














0












0








0






You can do this multi-condition join by matching an object on each side of the join condition. This can be a typed object, but an anonymous object is also fine, provided that the property names match. The relevant part of your query should look something like this:



//Start here
join ve in db.Value_Entry on new {
DocNo = sih.Document_No_,
LineNo = sih.Line_No_ } equals new {
DocNo = ve.Document_No_,
LineNo = ve.Document_Line_No_ }





share|improve this answer












You can do this multi-condition join by matching an object on each side of the join condition. This can be a typed object, but an anonymous object is also fine, provided that the property names match. The relevant part of your query should look something like this:



//Start here
join ve in db.Value_Entry on new {
DocNo = sih.Document_No_,
LineNo = sih.Line_No_ } equals new {
DocNo = ve.Document_No_,
LineNo = ve.Document_Line_No_ }






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 10:05









cf_encf_en

1,458618




1,458618












  • Thanks cf_en :)
    – The First
    Nov 13 '18 at 10:31


















  • Thanks cf_en :)
    – The First
    Nov 13 '18 at 10:31
















Thanks cf_en :)
– The First
Nov 13 '18 at 10:31




Thanks cf_en :)
– The First
Nov 13 '18 at 10:31


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278018%2fhow-to-join-two-columns-from-table-a-with-two-columns-from-table-b-linq-join-m%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python