anybody know why in Asp.net mvc the data is in the database but not showing up on the index
I have a order and cusotmers model. When i add a .includ customer in the order query. it jsut show tow reuslts. EVen thou there is mroe in the databse. All the relastionships are set up correctly as it is adding to data base
43 Replies
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/one sec
hey @ZZZZZZZZZZZZZZZZZZZZZZZZZ, The probelm I have is adding the include stament include cusotmers only shows these two reuslts. Even though if you look at the pciture of the database there is alot more. Do you have any idea why this happing i have spent like 10 hours trying to fix this.
Not sure what that
.heic
file isoh it was a image of the database
why is the include customers braking it if i dont put that i will display everthing.
The cusomter mdoel inheirtes form the built in apilalction user class but all the relastioships are set up right as it is adding to the data base
@ZZZZZZZZZZZZZZZZZZZZZZZZZ
Well, it seems fine to me
As in, it shoul;d be fetching all orders
yes
including cusotmers if i remove the incldue cusomter it works its shwos everhting
What happens when you ditch the includes and use a select instead?
do you have any idea why it is not
so that would be select cusomter
ill try
No
That would be selecting the data into a DTO class
oh ok
what do you mean by this
I mean exactly and precisely what I said
for example
i am trying that rn thanks
i feel this could be the same reason the .include did not work as well
could this be beacuse cusomter is iherting form the identiy user pre built in class
@ZZZZZZZZZZZZZZZZZZZZZZZZZ
What is
Customers
?
Is it a collection of customers?a class
yes
Why does the error imply that it is, in fact, not?
ill show you my model
thats in orders
That does not look like a collection to me
oh my bad but one order can only have one cusotmer
Why is it named plural, "Collections" then
idk i though thats just naming convetion
That's the worst naming convention I've seen in my entire life and fuck whoever decided to impose it on this project
Regardless
Since it's not a collection, we cannot use LINQ
So... you just get what you need from the customer directly
for example
oh so on the front end I can not be like cusotmers.name etc
You can just fetch the whole customer, sure
is there a way to get everthing
But do you need to?
ya ig becuase the admin should be able to see the cusotmers detials
do i have to type each feild or is there a way to select the whole thing
You can just do
Customer = o.Customers
igok ill try thank you one last thing
is there a way to do it wihto a dto
or is it needed
since it is not a collection
The way to do it without a DTO is the way you were doing it before
Which is suitable for school projects
but that dosent work
But only to a point, then I'd start docking points
It should work
Which is why I told you to try the proper way, using a DTO
If that still doesn't work, something else is broken
ok thankk yoiu very much