CoreVisional
Difference in using the second overloaded method and first method from CosmosClient
Hi, I am trying to understand what's the difference in using the second overloaded method in CosmosClient compared to just supply the connection string using the first overloaded method of CosmosClient? I understand that the second requires me to provide the endpoint uri and primary key, but why is there a need for the second overloaded method if
CosmosClient(string connectionString, CosmosClientOptions clientOptions = null)
already simplifies my work. Is there a reason(s) that I should be using the second one? Note that I am using the latest Azure CosmosDB SDK v3 for my ASP.NET Core 7 application.36 replies
Refactoring long if statement that checks for user roles
Hi, I'm trying to find a cleaner way of refactoring this if code block that checks for each user role. The if statement works but looks really messy, and I was wondering if it's possible to do something like how EF Core would do, just check if it contains something using
.Contains()
.
22 replies
❔ How to pass anchor tag values to controller to render view based on selected value
HI, how do I pass the values assigned to an anchor tag to the controller so that the controller can render the view or filter out what to show to the user? For example, I have in my views
Controller
I'm not sure how to do something like this in ASP
8 replies
Get data from a model and display it as dropdown on client side in Razor
Hi, how do I retrieve data in a database from a model and show it in as my dropdown values in my razor view? For example, I have model called "Block", and I have a model called "ClassroomLocation", then on client side, there's a dropdown with "Block" as selection. But the values I'm not sure how to generate it based on the data stored inside "Block".
Do I have to use something called model binding? These two models are also non-relational to each other.
5 replies
❔ The type or namespace name Model could not be found
Hi, I'm facing an error on a missing directive when trying to specify the model name in my view model. I'm not sure if this works on Models directory but it works across controllers and views, so I assume it does. So, I have all my imports called in "_ViewImports", and this includes the model directory. However, when I wanted to use the model name, I get the error. I mean, calling the import inside the view model solves the issue, but I was looking to not include it in since I already have "_ViewImports". For example,
Then the error appears on "ModelName"
8 replies
❔ Naming enum value for level or floor for a building
Hi, so, I've read some posts saying it is not descriptive at all to name enum values like "One", "Two", "Three", etc.. However, if it is used for a building where there's level/floor, wouldn't it make sense to name it as those aforementioned values? Or should it be like "LevelOne", "LevelTwo", etc...
25 replies
❔ Display data saved in database in a specified format
Hi, how can i display the value in a specific format than the one saved in database? For example, I have in my database
When retrieving data from the database and showing it in a table, how do I make it display "Level 1", "Level 2", instead of "LevelOne", "LevelTwo"?
13 replies
Display value of EnumMember on Razor Page View
Hi, how do I display the value defined in my enum using EnumMember and have the value displayed on my razor page? For example, I want to display "Block A", "Block B", etc.. instead of BlockA, BlockB
1 replies
Get values from an Enum class and perform checking
Hi, I am trying to get the values from an enum and perform a conditioning checking with the values retrieved. I was told that the way I am trying to check is fine but the way I am checking it is incorrect. Here's an example of what I am trying to get. It was hinted that the if statement is incorrect.
24 replies
How to put enum values in a list [SOLVED]
Hi, I'm quite new to C# and I'm still learning, but I'm tasked to debug a piece of code using C#, I managed to fix it but I have like a super long if statement that contains the same thing, except for the values of enum. I came from Python and usually, I'd just declare a list like
my_list = [1, 2]
, but from what I found, I just need to use Enum.GetValues().11 replies