hippiewho
hippiewho
CC#
Created by Tratt on 12/29/2024 in #help
.NET Core OnModelCreating gives me error
ah, i agree. Its also more performant than GUIDs during scanning but meh people like the GUIDs as Ids - more power to them
26 replies
CC#
Created by Tratt on 12/29/2024 in #help
.NET Core OnModelCreating gives me error
Just confused, are you saying that you think hardcoding the GUID is bad practice or using GUIDs as ids?
26 replies
CC#
Created by Tratt on 12/29/2024 in #help
.NET Core OnModelCreating gives me error
The error is because you are seeding data with Guid.NewGuid(). This means that when OnModelCreate runs the guid will be different every time (i believe a similar issue can happen when using DateTime.Now). If this is an existing code base (or if too lazy - if its a personal project) then you can simply suppress the error and fix later. If possible though you should change the seed data to use an explicit non changing GUID.
26 replies
CC#
Created by Fatih on 7/28/2023 in #help
✅ Model not binding to View' issue in ASP.NET
It shouldnt be necessary though and I can't find anything wrong with your code 🤔
12 replies
CC#
Created by Fatih on 7/28/2023 in #help
✅ Model not binding to View' issue in ASP.NET
Maybe add [FromBody] to the parameter list? Like:
Register([FromBody] RegisterModel model)
Register([FromBody] RegisterModel model)
12 replies
CC#
Created by Slem P on 11/16/2022 in #help
❔ C code wont run
Gonna need a little more info
8 replies
CC#
Created by Slem P on 11/16/2022 in #help
❔ C code wont run
Or is it that the insert doesnt work?
8 replies
CC#
Created by Slem P on 11/16/2022 in #help
❔ C code wont run
It doesnt start?
8 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
Actually you got me thinking and so i just tested this out. I was wrong, you would need to make the values of the enum into powers of 2. By default enums are start at 0 get assigned a value +1 greater than the previous. Has flag only works correctly if the values are non zero and power of two. The flags attribute can enforce that rule but HasFlag is part of the enum type and can be used (incorrectly) when the enum is not power of 2
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
I honestly dont remember the reasons for the restrictions
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
The has flag works rgardless because at its core its a bitwise check (IIRC). The flags attribute markes the enum as a powers of 2 flag (under the hood it uses binary flags - 0001, 0010, 0100, 1000, etc)
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
The flags attribute should really only be used when the enums values are base 2. ei 0,1,2,4,8,16,etc EDIT: meant powers of 2
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
Well if you added the Weekends values to Days then all you would need to do is bool isWeeknd = Days.Weekends.HasFlag(day.Day); Assuming day.Day is of enum type Days
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
yup thats reasonable lol
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
Tho i guess this would create issues if you try to dynamically enumerate the values into a list or somethin
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
I ask because maybe it would be cleaner to do something like
enum Days{
Mon,
Tues,
...,
Saturday,
Sunday,
Weekends = Saturday|Sunday
}
enum Days{
Mon,
Tues,
...,
Saturday,
Sunday,
Weekends = Saturday|Sunday
}
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
Bitwise ops are a little faster i think but really its negligible. Im curious tho, is the weekends enum new or does it exist in your code base already?
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
nope
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
do you need it? you cant use it if you want to use HasFlag
75 replies
CC#
Created by CoreVisional on 11/15/2022 in #help
❔ Compare Enum Values with submitted value
are you using the flags attribute?
75 replies