KidKai25
KidKai25
CC#
Created by KidKai25 on 7/19/2024 in #help
Advantage of async
I have actions methods like these
public ActionResult GetData1()
{
var data = FetchData1FromDatabase();
return Json(data, JsonRequestBehavior.AllowGet);
}

public ActionResult GetData2()
{
var data = FetchData2FromDatabase();
return Json(data, JsonRequestBehavior.AllowGet);
}

public ActionResult GetData3()
{
var data = FetchData3FromDatabase();
return Json(data, JsonRequestBehavior.AllowGet);
}
private List<MyData> FetchDataFromDatabase()
{
using (var db = new MyDbContext())
{
return db.MyData.ToList();
}
}
public ActionResult GetData1()
{
var data = FetchData1FromDatabase();
return Json(data, JsonRequestBehavior.AllowGet);
}

public ActionResult GetData2()
{
var data = FetchData2FromDatabase();
return Json(data, JsonRequestBehavior.AllowGet);
}

public ActionResult GetData3()
{
var data = FetchData3FromDatabase();
return Json(data, JsonRequestBehavior.AllowGet);
}
private List<MyData> FetchDataFromDatabase()
{
using (var db = new MyDbContext())
{
return db.MyData.ToList();
}
}
what happens if I dont make them async? Server can still process them concurrently right? By making a new thread.
14 replies
CC#
Created by KidKai25 on 7/10/2024 in #help
What causes these 2 packages? How to fix this.
No description
14 replies
CC#
Created by KidKai25 on 6/28/2024 in #help
✅ Is it a good idea to store CSS class as a property in my C# model?
Example
class UserStatus
{
string StatusName {get;set;}
string StyleClass {get;set;}
}
class UserStatus
{
string StatusName {get;set;}
string StyleClass {get;set;}
}
Then I store like "Online","green-circle" "Offline", "red-circle" Or should I check the status and then add the css in my js code itself?
14 replies
CC#
Created by KidKai25 on 5/17/2024 in #help
You favourite extensions in visual studio 2022?
I have SonarLint.
8 replies
CC#
Created by KidKai25 on 3/28/2024 in #help
No way to back to the Try block?
No description
4 replies
CC#
Created by KidKai25 on 3/11/2024 in #help
Must know design pattern?
whats your favourite design pattern or you think is one must know one or the one you keep seeing in the standard code?
30 replies
CC#
Created by KidKai25 on 11/30/2023 in #help
How to go back to code line in try after Exception occurs?
No description
6 replies
CC#
Created by KidKai25 on 10/19/2023 in #help
❔ running an mvc in .net framework(not core) whose output type is a library?
How to do it? I get ""Unable to run your project. The "RunCommand" property is not defined."" https://github.com/MiniProfiler/dotnet/tree/main/samples/Samples.Mvc5 This is the one.
12 replies
CC#
Created by KidKai25 on 6/28/2023 in #help
❔ How are we able to use AsEnumerable to something old class like DataTable? Tell me like I am 10.
DataTable came first than AsEnumerable. How did they do it?
14 replies
CC#
Created by KidKai25 on 4/20/2023 in #help
❔ Anyone experienced, would you be interested in mentoring me?
I am looking for anyone well experienced to just give me a "direction" and keep me in check. I am not someone who is like very passionate about coding. I like it but in bits. And I have always preferred quality over quantity though I know very well one learns the best by getting his/her hands dirty. I lack this quality. So I was hoping if someone would be interested...please reach out 🙂 What's in it for you? Well, I could buy you a coffee, perhaps even every week if that's okay? 😅
74 replies
CC#
Created by KidKai25 on 3/5/2023 in #help
❔ Must read books!?
What are some books that have really helped you become better skilled?
51 replies
CC#
Created by KidKai25 on 2/3/2023 in #help
✅ What's your view on tool like Sonarqube?
Should I learn from the code smells it captures?
67 replies
CC#
Created by KidKai25 on 1/20/2023 in #help
✅ What is the use of these different versions of the same DLL?
5 replies
CC#
Created by KidKai25 on 1/11/2023 in #help
❔ Commandments for C# developers?
Came across this cool article http://www.lysator.liu.se/c/ten-commandments.html I was thinking what according to you should be the commandments for C# 🙂
101 replies
CC#
Created by KidKai25 on 12/23/2022 in #help
❔ ✅ What is the bestright thing to do when an Exception occurs say, in my MVC application?
Catch the exception and log Catch the exception and do nothing. Throw the exception. Do nothing. It depends on me as a dev
11 replies
CC#
Created by KidKai25 on 12/8/2022 in #help
❔ Idea for better approach for below problem?
Earlier: Local File System New Requirement: Integrate Azure storage system (Make configurable b/w File and Azure) My Idea: Create an Interface acting as an abstraction for client (Using factory method) Based on config either Azure or File will be used. Client code won't know. Client just ask for StorageObject and call Create/Download/Delete methods.
Interface IMyStorageObjectInterface
{
Create();
Download();
....
}
Interface IMyStorageObjectInterface
{
Create();
Download();
....
}
So,
IMyStorageObjectInterface storageObject = Storage.GetStorage(); //factory method
storageObject.Create(path); //Create would either upload on cloud or local
IMyStorageObjectInterface storageObject = Storage.GetStorage(); //factory method
storageObject.Create(path); //Create would either upload on cloud or local
Problem: I see a 3rd party library being used in some existing methods in the application 3rdPartyConvert&UploadMethod(string/stream filepath) I guess the above method will successfully upload file given right path(local file path). But how to do this with my Abstract methods(MyStorageInterface) for the client? Should I let the 3rdParty upload method do its work and then upload via my method(for file system, replace/ignore and for cloud upload it)? Maybe Create an overload of the method (Making such change in each of such methods)? <br> Any other perhaps, better ideas?
2 replies
CC#
Created by KidKai25 on 12/7/2022 in #help
❔ Roslyn compiler magic?
I have this WebAPI project in dotnet framework 4.7 I replace a dll manually in bin and bin/roslyn folder I run the project add references to dlls(say, to the bin folder). All good. But then I see the old dll has come back to bin/roslyn and when I see the reference in VS I see the path is also now of bin/roslyn
11 replies
CC#
Created by KidKai25 on 10/31/2022 in #help
How does the flow of information takes place when something new comes up?
Say something new get released (.net 7), and something new 'X' has been introduced. To understand X do self learners try their hands using the available documentation and share with others. Or it's like Microsoft's developers share how to use 'X' in their blog and from that you start your own learning further?
8 replies
CC#
Created by KidKai25 on 10/31/2022 in #help
My head hurts understanding this LINQ
static IEnumerable<string> serializeToEnumerable(TreeNode root)
=> root is null
? new string[] { String.Empty }
: serializeToEnumerable(root.left)
.Concat(serializeToEnumerable(root.right))
.Prepend(root.val.ToString());
static IEnumerable<string> serializeToEnumerable(TreeNode root)
=> root is null
? new string[] { String.Empty }
: serializeToEnumerable(root.left)
.Concat(serializeToEnumerable(root.right))
.Prepend(root.val.ToString());
27 replies
CC#
Created by KidKai25 on 9/14/2022 in #help
WTH is going in this code?
var ip = new double[] { 1, 2, 3 }; double sum = 0; var output = ip.Select(w => sum += w); var l1 = output.ToList(); //outputs 1,3,6 var l2 = output.ToList(); //7,9,12
19 replies