BekirK
✅ How to set enum default int value
Hi everyone, I have an enum type. For example as below. Normally, the value of enums in the db starts from 0. I know that if we want to start from 1, saying '=1' for the first value is enough.
The question I want to ask you about is that you can do this process automatically with typeconfiguration etc. Can I do it somewhere? The reason I want this is because I have many enums. And I want them all to start from 1. What do you think about it :)
40 replies
OData filtering
Hi everyone, I want to ask you something about OData,
I have roles for a user. And I separate these roles with ",". For example, there are roles such as;
user_1: "test_1, test_2"
user_2: "test_1"
user_2: "test_2, test_4"
I use OData when listing these roles. There is a filtering process on the FE side. However, since there is more than one role separated by commas, it gives the following error:
objA: (object)EF.Property<Guid?>(u, "Id"), \r\n objB: (object)EF.Property<Guid?>(u0, "UserId")))\r\n . Any() ? string.Join(\r\n separator: ",", \r\n values: DbSet<UserRole>()\r\n .Where(u1 => !(u1.IsDeleted))\r\n .Where( u1 => EF.Property<Guid?>(u, "Id") != null && object.Equals(\r\n )
How do you think I can do the filtering? When I filter as "test_2" I want user_1 and user_2 to appear.
3 replies
❔ Can Visual Studio potential fixes suggest nuget packages?
Hello, if you've used ReSharper in Visual Studio or Rider, you might be familiar with the feature where it suggests downloading the relevant NuGet package if you're using code from an uninstalled NuGet package. I'm wondering can I do this through settings or with an light extension(not ReSharper, cus it's heavy) in Visual Studio?
33 replies
❔ Getting the connectionString from appsetting.json
Hello everyone, in my project I am using a Generic build like this:
public class EfGenericRepository<TEntity, TContext> : IGenericRepository<TEntity> where TEntity : class, IEntity, new() where TContext : DbContext, new()
{
public void Add(TEntity entity)
{
using (TContext context = new TContext())
{
var addedEntity = context.Entry(entity);
addedEntity.State = EntityState.Added;
context.SaveChanges();
}
}
}
Any EntityDal class is like this:
public class EfCategoryDal : EfGenericRepository<Category, SimpraProjectContext>, ICategoryDal
{
}
Context class is like this
public class SimpraProjectContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=DESKTOP-xxx; Database=TestOne; Trusted_Connection=true; TrustServerCertificate=True");
}
// other codes
}
I couldn't perform the necessary operations to get the connectionString from appsetting.json. Can you help with this. (I'm using .net 6)21 replies