Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can i make an inner join work in linq c#

I have used this for the inner join

 var join = products.Join(
                            purchase,
                            
                            products => products.IdProd,
                            sales => sales.IdProd,
                            
                            
                            (products, sales) => new
                            {
                                Description = products.Description,
                                IdSale = sales.IdSale,
                                Cant= sales.Cant

                            });

        foreach (var obj in join)
        {

            Console.WriteLine("{0} - {2}", obj.Description, obj.IdSale,obj.Cant);
        }

My output:
My output is the follwing:

How can I make the join print the 3 values that I need?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I think you have a much simpler problem

 Console.WriteLine("{0} - {2}", obj.Description, obj.IdSale,obj.Cant);

you mean

Console.WriteLine("{0} - {1} - {2}", obj.Description, obj.IdSale,obj.Cant);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading