Monsieur Wholesome
Monsieur Wholesome
CC#
Created by Protagonist on 11/7/2024 in #help
Console Doesn't Clear and Provides nested outputs
Old output being overwritten with new output
102 replies
CC#
Created by Protagonist on 11/7/2024 in #help
Console Doesn't Clear and Provides nested outputs
It kinda looks like old output? Like a Windows Terminal Buffering error
102 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
Thaat is up to you to fix now
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
A good database design will teach you a thing or two about good practice :catlaugh:
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
Of course, you can scatter information about the existence of a file around the table, but it can and will in the long run hurt integrity Things will get lost, files will be deleted, and various tables need to be updated extensively
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
With a separate table for files, you'd have a centralized management point
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
The file class i gave as an example of what the table would probably look like
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
yes
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
In the db you change the column from byte[] type you were storing it as To an int Foreign Key, that points to a File object
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
public class File
{
public int Id { get; set; }
public string Name { get; set; }
public string Location { get; set; }
public ulong Size { get; set; }
}

public class FileManager
{
public File CreateFile(byte[] fileData, string fileName)
{
const string FileDirectory = "./Files";

var file = new File()
{
Name = fileName,
Size = fileData.Length,
Location = Path.Combine(FileDirectory, fileName)
};

File.WriteAllBytes(file, fileData);

// Save File to your sql database, which only contains an id, the name, maybe the file size and the Location of your file ("./Files/YourFileName.txt")
// You can then reference the File within whatever other database row you have via its id
SaveFileToDatabase(file);

return file;
}
}
public class File
{
public int Id { get; set; }
public string Name { get; set; }
public string Location { get; set; }
public ulong Size { get; set; }
}

public class FileManager
{
public File CreateFile(byte[] fileData, string fileName)
{
const string FileDirectory = "./Files";

var file = new File()
{
Name = fileName,
Size = fileData.Length,
Location = Path.Combine(FileDirectory, fileName)
};

File.WriteAllBytes(file, fileData);

// Save File to your sql database, which only contains an id, the name, maybe the file size and the Location of your file ("./Files/YourFileName.txt")
// You can then reference the File within whatever other database row you have via its id
SaveFileToDatabase(file);

return file;
}
}
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
And relational databases are very very expensive to host So it's just not a good practice
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
Huge amounts of data (images, arbitrary binary data, big amounts of texts, etc etc) make databases slow
61 replies
CC#
Created by PANZER234425 on 10/6/2024 in #help
Improving performance / caching
I approve of what Z said
61 replies
CC#
Created by ZML on 7/12/2024 in #help
Handling Nullable Property Updates in ASP.NET
The requester has to send the value
7 replies
CC#
Created by Alta on 7/9/2024 in #help
EF Core - Where clause on multiple field in object list
I can think of two ways 1 (Slow, not really nice): If its a small list of lignesClients of like 2 - 5 elements, you could build Expressions at runtime that will basically become
SELECT *
FROM LienCommandeClientCommandeFournisseur
WHERE (NumeroJournalClient = 'A1' AND NumeroPieceClient = 'B1' AND NumeroLigneClient = 'C1')
OR (NumeroJournalClient = 'A2' AND NumeroPieceClient = 'B2' AND NumeroLigneClient = 'C2')
OR (NumeroJournalClient = 'A3' AND NumeroPieceClient = 'B3' AND NumeroLigneClient = 'C3')
SELECT *
FROM LienCommandeClientCommandeFournisseur
WHERE (NumeroJournalClient = 'A1' AND NumeroPieceClient = 'B1' AND NumeroLigneClient = 'C1')
OR (NumeroJournalClient = 'A2' AND NumeroPieceClient = 'B2' AND NumeroLigneClient = 'C2')
OR (NumeroJournalClient = 'A3' AND NumeroPieceClient = 'B3' AND NumeroLigneClient = 'C3')
2 (Fast, pretty cool, yo!): Hoping that your lignesClients is an IEnumerable (or array or list) that comes from an IQueryable query, and making sure it stays an IQueryable, so that you can make it a sub-query within your query here with what @ZZZZZZZZZZZZZZZZZZZZZZZZZ suggested, which should translate into something like
SELECT LCCCF.*
FROM LienCommandeClientCommandeFournisseur AS LCCCF
WHERE EXISTS (
-- Your Sub-Query
SELECT 1
FROM WhereverYouGetYourLignesClientsFrom AS S
WHERE
LCCCF.NumeroJournalClient = S.NumeroJournalClient
AND LCCCF.NumeroPieceClient = S.NumeroJournalClient
AND LCCCF.NumeroLigneClient = S.NumeroJournalClient
)
SELECT LCCCF.*
FROM LienCommandeClientCommandeFournisseur AS LCCCF
WHERE EXISTS (
-- Your Sub-Query
SELECT 1
FROM WhereverYouGetYourLignesClientsFrom AS S
WHERE
LCCCF.NumeroJournalClient = S.NumeroJournalClient
AND LCCCF.NumeroPieceClient = S.NumeroJournalClient
AND LCCCF.NumeroLigneClient = S.NumeroJournalClient
)
23 replies
CC#
Created by Alta on 7/9/2024 in #help
EF Core - Where clause on multiple field in object list
Ofc you can do it with ints, strings and what not, but not with a complex type where 1 element consists of 3 columns / properties Edit: Though with SQL Server json columns and json functions (OPENJSON() and stuff) it could with some black magic be possible maybe, though I imagine not
23 replies
CC#
Created by Alta on 7/9/2024 in #help
EF Core - Where clause on multiple field in object list
That's not a complex type though
23 replies
CC#
Created by Alta on 7/9/2024 in #help
EF Core - Where clause on multiple field in object list
It works for Linq yee, but cannot be expressed in sql
23 replies
CC#
Created by Alta on 7/9/2024 in #help
EF Core - Where clause on multiple field in object list
I was gonna say You expect passing a list of complex objects to EFC works? 😄
23 replies