Click here to Skip to main content
15,885,537 members
Home / Discussions / C#
   

C#

 
GeneralRe: Disabling events of objects stored in array Pin
Pogoodill5-Jan-18 6:13
Pogoodill5-Jan-18 6:13 
AnswerRe: Disabling events of objects stored in array Pin
BillWoodruff6-Jan-18 2:12
professionalBillWoodruff6-Jan-18 2:12 
AnswerRe: Disabling events of objects stored in array Pin
Gerry Schmitz6-Jan-18 6:55
mveGerry Schmitz6-Jan-18 6:55 
QuestionGet current point in time in recurring time interval. Pin
Member 136084655-Jan-18 2:10
Member 136084655-Jan-18 2:10 
AnswerRe: Get current point in time in recurring time interval. Pin
Ralf Meier5-Jan-18 2:38
mveRalf Meier5-Jan-18 2:38 
AnswerRe: Get current point in time in recurring time interval. Pin
Gerry Schmitz6-Jan-18 7:06
mveGerry Schmitz6-Jan-18 7:06 
QuestionHow to fetch master detail data using EF and LINQ Pin
Mou_kol5-Jan-18 0:15
Mou_kol5-Jan-18 0:15 
AnswerRe: How to fetch master detail data using EF and LINQ Pin
Vincent Maverick Durano5-Jan-18 2:20
professionalVincent Maverick Durano5-Jan-18 2:20 
Your example should should theoretically work. Here's an example using join with syntax-based query in EF:

C#
var order = (from o in _ctx.order
                 join od in _ctx.orderdetails on o.OrderID equals od.OrderID
                 where o.OrderID == _OrderID).ToList();


To select specific fields, you could either use an anonymous type object like this:

C#
var order =  _ctx.order
            .Include(x => x.orderdetails)
            .Where(x => x.OrderID== _OrderID)
            .Select(x => new
            {
                 OrderID = x.OrderID,
                 SomeColumn = x.SomeColumn1,
                 SomeColumn2 =  x.SomeColumn1
            }).ToList();	 


Or use a strongly-typed object like this:

C#
var order =  _ctx.order
            .Include(x => x.orderdetails)
            .Where(x => x.OrderID== _OrderID)
            .Select(x => new OrderDetail
            {
                 OrderID = x.OrderID,
                 SomeColumn = x.SomeColumn1,
                 SomeColumn2 =  x.SomeColumn1
            }).ToList();	 


Noticed that the Select clause now use the OrderDetail. The OrderDetail is just a class that holds the properties that you want to use in your query.

For more information and examples on EF, I would recommend you to head over to the official documentation here: Entity Framework | Microsoft Docs[^]
GeneralRe: How to fetch master detail data using EF and LINQ Pin
Mou_kol6-Jan-18 6:08
Mou_kol6-Jan-18 6:08 
GeneralRe: How to fetch master detail data using EF and LINQ Pin
Vincent Maverick Durano8-Jan-18 15:33
professionalVincent Maverick Durano8-Jan-18 15:33 
QuestionPetaPoco (T4 Template) in .Net Core 2.0 for MSql : - SerializationException in generating Database.cs Pin
J Kaur4-Jan-18 15:18
J Kaur4-Jan-18 15:18 
AnswerRe: PetaPoco (T4 Template) in .Net Core 2.0 for MSql : - SerializationException in generating Database.cs Pin
BillWoodruff4-Jan-18 21:37
professionalBillWoodruff4-Jan-18 21:37 
PraiseRe: PetaPoco (T4 Template) in .Net Core 2.0 for MSql : - SerializationException in generating Database.cs Pin
J Kaur11-Jan-18 10:52
J Kaur11-Jan-18 10:52 
AnswerRe: PetaPoco (T4 Template) in .Net Core 2.0 for MSql : - SerializationException in generating Database.cs Pin
Vincent Maverick Durano5-Jan-18 1:59
professionalVincent Maverick Durano5-Jan-18 1:59 
PraiseRe: PetaPoco (T4 Template) in .Net Core 2.0 for MSql : - SerializationException in generating Database.cs Pin
J Kaur11-Jan-18 10:51
J Kaur11-Jan-18 10:51 
QuestionAdding Items in a Class Pin
Member 136074754-Jan-18 12:04
Member 136074754-Jan-18 12:04 
AnswerRe: Adding Items in a Class Pin
Mycroft Holmes4-Jan-18 12:41
professionalMycroft Holmes4-Jan-18 12:41 
AnswerRe: Adding Items in a Class Pin
BillWoodruff4-Jan-18 21:27
professionalBillWoodruff4-Jan-18 21:27 
AnswerRe: Adding Items in a Class Pin
OriginalGriff4-Jan-18 21:39
mveOriginalGriff4-Jan-18 21:39 
Questionlistview to combobox - HELP Pin
Member 136074164-Jan-18 10:31
Member 136074164-Jan-18 10:31 
QuestionRe: listview to combobox - HELP Pin
Gerry Schmitz4-Jan-18 10:40
mveGerry Schmitz4-Jan-18 10:40 
AnswerRe: listview to combobox - HELP Pin
Member 136074165-Jan-18 12:32
Member 136074165-Jan-18 12:32 
GeneralRe: listview to combobox - HELP Pin
Gerry Schmitz6-Jan-18 6:28
mveGerry Schmitz6-Jan-18 6:28 
GeneralRe: listview to combobox - HELP Pin
Member 136074167-Jan-18 3:59
Member 136074167-Jan-18 3:59 
GeneralRe: listview to combobox - HELP Pin
Gerry Schmitz7-Jan-18 7:10
mveGerry Schmitz7-Jan-18 7:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.