by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Skeferstat
    @Skeferstat
    I see, if proxies are active, that the return type changes to proxy classes. In my debugger I see all data correct. All properties are filled with right values. But in swagger this properties with values like "string".
    So dbcontext returns all data correctly.
    Skeferstat
    @Skeferstat
    What is the right way to get data async from database within a repository pattern, include this repository in a controller and then access this api with a htpp client? Where is await needed and in the right place?
    Anthony Iacono
    @AnthonyIacono12_twitter
    Do you mind sharing your implementation of Get()?
    Skeferstat
    @Skeferstat

    No problems, here is nothing special...
    Repository

    public Task<List<Address>> Get()
    {
    return _context.Adresses.ToListAsync();
    }

    Controller:

    public async Task<List<Address>> Get()
    {
    return await _repository.Get();
    }

    Anthony Iacono
    @AnthonyIacono12_twitter
    So it looks pretty standard, nothing crazy here. Here's a better question: What do you hope to accomplish by adding UseLazyLoadingProxies?
    Skeferstat
    @Skeferstat
    Get the navigation properties automatically
    And the InverseProperty
    Anthony Iacono
    @AnthonyIacono12_twitter

    So you don't want to have to do like:
    _context.Addresses.Include(a => a.User).ToListAsync()

    for example?

    Skeferstat
    @Skeferstat
    I have a class Adress and an adress has a "parent" address. So I need all the sub-addresses of an adress, and the for each sub-address hers sub-adresses and so on...
    So _context.Addresses.Include(a => a.InversePropertyForAddress) returns only the sub-adresses for the first level...
    so if adress1 has 5 sub-adresses and I call GetById(string addressId) then I get all 5 subadresses. But foreach sub-address the InversePropertyForAddres is empty. But I know, that der second sub-Address has two sub-addresses to...
    Anthony Iacono
    @AnthonyIacono12_twitter
    Ooh okay. So you want all the addresses, those addresses's parent addresses, and over and over until there are no more parents to the parents
    That's very interesting, I've never had to do that with EF core. But honestly I don't think that is what UseLazyLoadingProxies is for
    Navigation properties are lazy loaded by default (every time that I've ever used them)
    Skeferstat
    @Skeferstat
    Is there any another way how I can access this data?
    Skeferstat
    @Skeferstat
    okay, I think, I have more logical problem.. ;) I will rewrite my logic ;)
    Skeferstat
    @Skeferstat
    Hi, I have a asp.net core application and a .net standard library. Both should use the same dbcontext. How I can inject the dbcontext to the .net standard library? Thansk in advance!
    Joe4evr
    @Joe4evr
    @Skeferstat this is a good opportunity for you to learn about layering and loose coupling
    an easy thing to do would be to move your DbContext down to a new library that both other projects depend on, but you may already see why that would be impractical, especially since you're likely to have tweaked the DbContext to specifically suit the app
    Joe4evr
    @Joe4evr
    the more general approach is to define an interface - maybe in the library you mentioned, maybe in a new library that both will depend on
    and this interface will define the set of operations you need, like your basic CRUD functions and other things: this is your I{Thing}Repository
    in your lib, you accept an instance of the repository as a dependency in places where you need it
    and in your app, you create a class that implements that repository interface that accepts the DbContext as a dependency
    Skeferstat
    @Skeferstat
    Okay, but one more question. I'm asp.net core I can inject dbcontext into a repository, like MyRepository(DBContext context). So, ms yu
    So, my question is, can I inject the db context the same way into a class library?
    Joe4evr
    @Joe4evr
    not directly, because your DbContext is defined above the library, and in project layering you can only utilize types that are defined below it
    that's the reason you create a repository interface at that project level, with its implementation higher up so the DbContext can get injected there and the interface providing the ability to be passed to services lower down
    Michał Zegan
    @webczat
    ef framework core question, playing randomly with queries and npgsql, observing what it generates. is it possible to make it to generate subqueries?
    Michał Zegan
    @webczat
    got it actually :P
    blizzardsolution
    @blizzardsolution
    hello, could anyone help me with connecting azure postgresql in asp.net core 3.1?
    Using this connection string: Server={host}.postgres.database.azure.com;Database={your_database};Port=5432;User Id={user_id};Password={your_password};Ssl Mode=Require;, i tried to publish the web api to azure services, but got a deploy error
    Alberto Passalacqua
    @AlbertoPa
    @blizzardsolution this should help: https://www.dotnetcurry.com/aspnet/1410/aspnet-core-app-postgresql-azure
    Once you have the connection string, install the npgsql plugin for EF Core, set the connection string and use something like this in your Startup.cs in place of the instructions for SQLServer:
    services.AddDbContext<ApplicationDbContext>(options =>
                    options.UseNpgsql(
                        Configuration.GetConnectionString(
                            "DefaultConnection"));
    blizzardsolution
    @blizzardsolution
    @AlbertoPa , thanks for replying!! i installed npgsql package and used the same code in Startup.cs
    trying to deploy the api to azure, i got the dploy error:
    C:\Program Files\dotnet\sdk\3.1.202\Sdks\Microsoft.NET.Sdk.Publish\targets\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(140,5): Error : Web deployment task failed. (The value 'Server={host}.postgres.database.azure.com;Database={your_database};Port=5432;User Id={user_id};Password={your_password};Ssl Mode=Require;' is not a valid connection string or an absolute path.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_INVALID_CONNECTION_STRING.)
    
    The value 'Server={host}.postgres.database.azure.com;Database={your_database};Port=5432;User Id={user_id};Password={your_password};Ssl Mode=Require;' is not a valid connection string or an absolute path.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_INVALID_CONNECTION_STRING.
    Keyword not supported: 'port'.
       at System.Data.SqlClient.SqlConnectionStringBuilder.GetIndex(String keyword)
       at System.Data.SqlClient.SqlConnectionStringBuilder.set_Item(String keyword, Object value)
       at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
       at System.Data.SqlClient.SqlConnectionStringBuilder..ctor(String connectionString)
       at Microsoft.Web.Deployment.ConnectionStringMatcher.RemoveExtraSlashFromDataSourceName(String connectionString)
       at Microsoft.Web.Deployment.ConnectionStringMatcher.GetStandardConnectionString(String userConnectionString, Boolean isSqlCE)
       at Microsoft.Web.Deployment.SqlInfo.GetBuilder(String connectionString, String errorMessageFormat)
    Publish failed to deploy.
    
    2>Build failed. Check the Output window for more details.
    Alberto Passalacqua
    @AlbertoPa
    uhm interesting... what do they give in their screen for the connection string? Maybe they dropped the Port option and force one? :-?
    blizzardsolution
    @blizzardsolution
    Actually, port 5432 is included in the connection string
    Alberto Passalacqua
    @AlbertoPa
    that error seems odd indeed
    have you tried asking in https://gitter.im/npgsql/npgsql ?
    blizzardsolution
    @blizzardsolution
    image.png
    this is my web deploy setting
    nope, not tried asking there
    Alberto Passalacqua
    @AlbertoPa
    probably a minor detail that is hard to spot... as usual :-(
    blizzardsolution
    @blizzardsolution
    i see :( ... where should I ask about this?
    Alberto Passalacqua
    @AlbertoPa
    if you have an Azure subscription, I'd bug them ;-)
    they seem responsive on Twitter in my limited experience
    blizzardsolution
    @blizzardsolution
    okay, got you. thank you
    Alberto Passalacqua
    @AlbertoPa
    the gitter channel I posted above may also help... doesn't hurt to try
    SIkebe
    @SIkebe
    Is there anyone who are using ASP.NET Core Identity with Oracle? It has been 8 months since .NET Core 3.0 released, but ODP.NET for EF Core 3.0 or later has not been released yet. (There isn't even a beta version...)
    oracle/dotnet-db-samples#49
    Joe4evr
    @Joe4evr
    tbh, that's an Oracle problem
    SIkebe
    @SIkebe
    Yeah, definitely :confused:
    alealpha2000
    @alealpha2000
    hi! i am looking for some advice. i am writing an app that needs to retry post requests. how do I ensure the server detects a post retry and returns a cached response when a retry is detected? is there any "official" way to do that?
    duckblaster
    @duckblaster
    general method is to add a request id to the original request, retries use the same request id, backend ignores it if it has seen that id before