C
C#5mo ago
🙈

✅ Ef Query

I have a var called SaleD is is bassed of the model sales which contiand a public product product and qaunitty and product id etc. I want to write a query to select SaleD.Product and ordrbydecedning a the total SaleD quanity sold for each saleD product.
50 Replies
Jimmacle
Jimmacle5mo ago
what do you have so far?
🙈
🙈5mo ago
i tried but idont how to do it so i have nothing right now
Jimmacle
Jimmacle5mo ago
we can't go off nothing even if your attempt was wrong we can show you where it's wrong
🙈
🙈5mo ago
ok ill show you my attempt ya its complpety wrong
Jimmacle
Jimmacle5mo ago
share actual code not something you typed out in here this is a place where you can come with a specific problem and details and show us what you've tried so we can help you, not a place for someone to do all the work for you
🙈
🙈5mo ago
one sec i changed it up but sitll no work
Jimmacle
Jimmacle5mo ago
$code
MODiX
MODiX5mo ago
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/
🙈
🙈5mo ago
i cant get disocrd on the laptop which the code is
Jimmacle
Jimmacle5mo ago
then it's going to be very difficult to help anyway, read the error message and see what it says
🙈
🙈5mo ago
it runs like a potato
Jimmacle
Jimmacle5mo ago
look at it this way: the more effort you put into getting help, the better help you will receive
🙈
🙈5mo ago
food dose not contain a defination
Jimmacle
Jimmacle5mo ago
so what does that mean?
🙈
🙈5mo ago
i am just confused how to write the query
Jimmacle
Jimmacle5mo ago
this isn't a query problem yet you need to know what members you defined on your own types if a food item doesn't have a salesData property then what you wrote doesn't make sense
🙈
🙈5mo ago
slaes data contains foods
Jimmacle
Jimmacle5mo ago
but you have a food item what properties are on your food item?
🙈
🙈5mo ago
my bad sales data also contians quanity i removed food item
Jimmacle
Jimmacle5mo ago
but you clearly don't have a salesData on foodItem don't remove random things i want you to understand why you're getting the error you're getting
🙈
🙈5mo ago
i have sales data
Jimmacle
Jimmacle5mo ago
do you understand the error you had?
🙈
🙈5mo ago
yes it was a mistake
Jimmacle
Jimmacle5mo ago
what was the mistake?
🙈
🙈5mo ago
food item was not thing
Jimmacle
Jimmacle5mo ago
i don't know what that means
🙈
🙈5mo ago
like i never had it
Jimmacle
Jimmacle5mo ago
then what type is in the _context.food dbset?
🙈
🙈5mo ago
yes but sales data is a vairble contaning orderedfood orderedfood is linked to foods
Jimmacle
Jimmacle5mo ago
where are you getting sales data from?
🙈
🙈5mo ago
its a var i made
Jimmacle
Jimmacle5mo ago
okay, here's the deal
🙈
🙈5mo ago
i did this as i want to aply filters
Jimmacle
Jimmacle5mo ago
i'm going to take a break and give you some time to get your thoughts together so you can clearly explain your code and your problem
🙈
🙈5mo ago
ight yes
Jimmacle
Jimmacle5mo ago
i'm not going to try and pull it out of you like this
🙈
🙈5mo ago
ok 5 minutes
Jimmacle
Jimmacle5mo ago
share as much code as possible that might be hard if you don't have discord on the same PC, but it's very important specifically your dbcontext and entity definitions at least try to get on discord in a browser or something
🙈
🙈5mo ago
ight
🙈
🙈5mo ago
No description
🙈
🙈5mo ago
Hi this is the probelm the qurey reutrns null sales data is not null i run debuger. What i want to get a list of all the food in sales data and display the sum of the quanity feild. So it will go throguh sales data group by food and sum all the quntity feilds where the product is the same @jIMMACLE @jIMMACLE
Jimmacle
Jimmacle5mo ago
i'm still waiting for you to do what i asked
🙈
🙈5mo ago
i did i made some progress i found out this works Var QuanititySolded = salesData.GroupBy(a => a.foods.Id).OrderBydescending(a => a.sum( a => a.Quanity)); the probelm i have is new I dont know how to acces quantiy sold to actually see if it works or not.
Jimmacle
Jimmacle5mo ago
because QuanititySolded is a collection, not a value look at what OrderBydescending returns
🙈
🙈5mo ago
how how do i show in view or see vlaues of the collection
Jimmacle
Jimmacle5mo ago
there are no values because you have not materialized the query all you've done so far is build a query, not execute one you should look through some guides on how EF Core works
🙈
🙈5mo ago
is it hard to do
Jimmacle
Jimmacle5mo ago
is what hard to do?
🙈
🙈5mo ago
This
Jimmacle
Jimmacle5mo ago
if you don't know what i mean by that you need to go back and reintroduce yourself to how EF Core works or go to your teacher/professor because at this point you aren't providing the information i'm asking for and i'm not going to spoonfeed you an answer
Want results from more Discord servers?
Add your server
More Posts
Can't open the properties of my program.when i try to open the properties of my program, this happensHow to insert an image from a MediaPicker into my database in C# (MAUI)Hello! 🙂 I'm new to MAUI and I'm facing challenges trying to insert an image from a MediaPicker intI need some help with attributeWelp I don't know much about attribute and GPT keeps sending me s*** code Anyone can give me an exaSystem.NullReferenceException: Object reference not set to an instance of an object.I'm developing a Asp.net Api which consist in the updating a existing Object into another, but when ✅ Setting app's address (Blazor 8 SSR)I have created a Blazor 8 wasm+ssr app, but after deployment my redirects broke. The app is hosted✅ How to Retrieve the Selected Item Value from a ComboBox in C# (AvaloniaUI)Hi, How can I get the value of the selected item in a ComboBox in C# (I'm using AvaloniaUI), please?Change function behavior depending on class' generic type.Hello! I was wondering if there was a way to change the behavior of a function in a class with a geGet my Webcam picture using AForge.netHi, so I want to make a simple file called getpic.cs with class called Module and a function Shot() Working on a school projectHey! So i’m working on musically themed class project where we are supposed to create a database usPairing Visual Studio (Windows) to a Mac to build an app remotely on the MacWhen I try to connect my Visual Studio to a Mac device I get stuck on the display of the message fro