Click here to Skip to main content
15,892,298 members
Home / Discussions / Database
   

Database

 
AnswerRe: database ER diagrime Pin
Richard MacCutchan26-Oct-19 4:18
mveRichard MacCutchan26-Oct-19 4:18 
AnswerRe: database ER diagrime Pin
Victor Nijegorodov26-Oct-19 5:21
Victor Nijegorodov26-Oct-19 5:21 
AnswerRe: database ER diagrime Pin
Mycroft Holmes26-Oct-19 13:05
professionalMycroft Holmes26-Oct-19 13:05 
GeneralRe: database ER diagrime Pin
Richard MacCutchan26-Oct-19 21:46
mveRichard MacCutchan26-Oct-19 21:46 
QuestionFetch data Pin
Member 1463481125-Oct-19 2:34
Member 1463481125-Oct-19 2:34 
AnswerRe: Fetch data Pin
Richard Deeming25-Oct-19 2:58
mveRichard Deeming25-Oct-19 2:58 
QuestionRe: Fetch data Pin
ZurdoDev25-Oct-19 4:22
professionalZurdoDev25-Oct-19 4:22 
Questionc# MongoDB Driver, find all products that contain a single brand name, and Group Distinct all category names, then get those categories. Pin
jkirkerx22-Oct-19 10:25
professionaljkirkerx22-Oct-19 10:25 
So I'm new to MongoDb; well I have about a year of experience, and I'm trying to write my first really complicated read.
What I'm trying to do, is grab a Brand by name, then all the products that match the brand name, then go through the products and get all the different distinct category names. Finally, grab the categories that match the list of category names.

So I'm just down to the final part, I have a list of distinct category names that are available by an enumerator, and I have a list of categories, I just can't figure out how to do the final part. I don't know what to call it either to search for help. I thought about a loop going through the categories, but I'm not sure how to unpack my distinct list of category names. Or perhaps the authors already thought of this and wrote something.

The categoryDistinct works.
categoriesSelected, my new list of categories
categories, a list of all the categories
var brandTask = _context.Brands.Find(b => b.Name == brandName).FirstOrDefaultAsync();

var productsFiltered = _context.Products.Find(b => b.Brand == brandName).ToList();
var categoriesDistinct = productsFiltered.GroupBy(c => c.Category).Select(x => x.FirstOrDefault());

var categoriesSelected = new List<Category>();
var categories = await context.Categories.Find( => true).ToListAsync();

// Use filters here for a more complex search of products
var productFilter = Builders<Product>.Filter.Eq("Brand", brandName);
var productsTask = _context.Products.Find(productFilter).ToListAsync();

await Task.WhenAll(brandTask, productsTask);

return new GetBrandPage { Brand = brandTask.Result, Categories = categoriesSelected, Products = productsTask.Result };
If it ain't broke don't fix it
Discover my world at jkirkerx.com

AnswerRe: c# MongoDB Driver, find all products that contain a single brand name, and Group Distinct all category names, then get those categories. Pin
jkirkerx22-Oct-19 10:41
professionaljkirkerx22-Oct-19 10:41 
QuestionHow do you separate in pages database results? Pin
Joan M21-Oct-19 10:00
professionalJoan M21-Oct-19 10:00 
AnswerRe: How do you separate in pages database results? Pin
David Mujica23-Oct-19 2:48
David Mujica23-Oct-19 2:48 
QuestionI have a column and i need to find in which table this column exists throughout whole DB Pin
Anandkumar Prajapati8-Oct-19 19:29
professionalAnandkumar Prajapati8-Oct-19 19:29 
AnswerRe: I have a column and i need to find in which table this column exists throughout whole DB Pin
Victor Nijegorodov8-Oct-19 20:46
Victor Nijegorodov8-Oct-19 20:46 
AnswerRe: I have a column and i need to find in which table this column exists throughout whole DB Pin
Jörgen Andersson8-Oct-19 21:11
professionalJörgen Andersson8-Oct-19 21:11 
Questionvb.net connection to a firebird database Pin
Member 767827622-Sep-19 17:15
Member 767827622-Sep-19 17:15 
AnswerRe: vb.net connection to a firebird database Pin
Victor Nijegorodov22-Sep-19 20:12
Victor Nijegorodov22-Sep-19 20:12 
GeneralRe: vb.net connection to a firebird database Pin
Member 767827623-Sep-19 11:06
Member 767827623-Sep-19 11:06 
GeneralRe: vb.net connection to a firebird database Pin
Member 767827623-Sep-19 16:16
Member 767827623-Sep-19 16:16 
QuestionMoving from access DB to Oracle to calculate average upon request Pin
Member 1447460719-Sep-19 11:12
Member 1447460719-Sep-19 11:12 
AnswerRe: Moving from access DB to Oracle to calculate average upon request Pin
Gerry Schmitz19-Sep-19 12:26
mveGerry Schmitz19-Sep-19 12:26 
QuestionMySQL database Pin
Alboyz17-Sep-19 16:46
Alboyz17-Sep-19 16:46 
AnswerRe: MySQL database Pin
#realJSOP18-Sep-19 1:08
mve#realJSOP18-Sep-19 1:08 
GeneralRe: MySQL database Pin
Alboyz18-Sep-19 16:58
Alboyz18-Sep-19 16:58 
AnswerRe: MySQL database Pin
Mycroft Holmes18-Sep-19 12:44
professionalMycroft Holmes18-Sep-19 12:44 
GeneralRe: MySQL database Pin
Alboyz18-Sep-19 16:58
Alboyz18-Sep-19 16:58 

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.