none
extracting data from two tables RRS feed

  • Question

  • Hi,

    I got two tables OrderHead and Labeldata, both these two tables dont have any relationship. I want to extract data from these two table , I am using following Linq:

    var ODetail = (from o in oContext.OrderHeads
                               join l in oContext.LIT04LABELDATA on o.CUSTORD equals l.ORDERNUMBER
                               where l.ORDERNUMBER == oNumber
                               select new { LIT04LABELDATA = l, OrderHead = o }
                             ).ToList();

     

    I want to use the data from both these tables, but I dont know how to extract data from var oDetail , Any suggestions.

    Thanks

     

    Wednesday, November 23, 2011 11:09 AM

Answers

  • Hi xFahadx;

    Something like this this will do.

    foreach( var data in ODetail )
    {
        // Access the fields of the joined records as follows:
        // For the fields of the table LIT04LABELDATA 
        var field1L = data.LIT04LABELDATA.FieldName;
        // For the fields of the table OrderHeads
        var field1OH = data.OrderHead.FieldName;
    	
        // Access all other fields in the same way 
    }
    

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, November 23, 2011 3:03 PM

All replies

  • Hi xFahadx;

    Something like this this will do.

    foreach( var data in ODetail )
    {
        // Access the fields of the joined records as follows:
        // For the fields of the table LIT04LABELDATA 
        var field1L = data.LIT04LABELDATA.FieldName;
        // For the fields of the table OrderHeads
        var field1OH = data.OrderHead.FieldName;
    	
        // Access all other fields in the same way 
    }
    

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, November 23, 2011 3:03 PM
  • Hi,

    I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?

    If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, November 28, 2011 3:53 AM
    Moderator