.net-core

How to set multiple services from Entity Framework Core on Repository Pattern?

孤街浪徒 提交于 2021-02-15 07:34:59
问题 I am trying to build a structure using repository pattern in entity framework core. I have an generic interface and a service for general operations. They simply do CRUD transactions. My interface: public interface IGeneralService<TEntity> where TEntity : class { void Delete(TEntity entityToDelete); void Delete(object id); IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = ""

How to set multiple services from Entity Framework Core on Repository Pattern?

半世苍凉 提交于 2021-02-15 07:34:16
问题 I am trying to build a structure using repository pattern in entity framework core. I have an generic interface and a service for general operations. They simply do CRUD transactions. My interface: public interface IGeneralService<TEntity> where TEntity : class { void Delete(TEntity entityToDelete); void Delete(object id); IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = ""

Delaying a task in C# - db context disposed

安稳与你 提交于 2021-02-15 04:59:28
问题 I have a situation where I need certain code to execute at a certain time (in my ASP .NET Core project). I know that delaying a task is not a great solution, but this is what I have and I'd like to know how to make it work: async Task MyMethod() { // do something // Create a new thread that waits for the appropriate time TimeSpan time = dbAppointment.ScheduledOn - TimeSpan.FromMinutes(5.0) - DateTime.UtcNow; _ = Task.Delay(time).ContinueWith(async x => await notificationManager.CreateReminder

How to get continuation token to pass in GetConversationsAsync?

断了今生、忘了曾经 提交于 2021-02-11 17:45:27
问题 I am building a bot service to integrate with Microsoft Teams. I am new so I found difficulties to sort things out. Here is the C# code and the string value was the continue token. var convo = ((BotFrameworkAdapter)turnContext.Adapter).GetConversationsAsync(turnContext, "", cancellationToken); 回答1: GetConversationsAsync uses the Get Conversations API. This API must be called many times in sequence in order to retrieve all the conversations a bot has participated in. The continuation token is

Set up CI with Travis for .NET Core

为君一笑 提交于 2021-02-11 17:11:49
问题 I'm trying to set up a CI for my .NET Core 3.1 class library. I created an account at https://travis-ci.org/github and selected my repository containing the code for my class library for a CI build. Travis is successfully watching my master branch for commits, but I cannot get the CI build to succeed. My repository: https://github.com/MintPlayer/MintPlayer.AspNetCore.SitemapXml Target framework: .NET Core 3.1 My latest .travis.yml file: language: csharp mono: none dotnet: 3.1.302 script: -

SignalR CORS same origin policy?

廉价感情. 提交于 2021-02-11 16:27:50
问题 When I run my angular app I get a CORS, although I've enabled it in my .NET core app, regular http requests seem to work fine, it's just with SignalR I'm having issues. Any suggestions would be much appreciated. Thanks in advance. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:5001/api/chat/negotiate. (Reason: expected ‘true’ in CORS header ‘Access-Control-Allow-Credentials’). Cross-Origin Request Blocked: The Same Origin Policy

When methods have the name …Async the exception “System.InvalidOperationException: No route matches the supplied values” occurs

核能气质少年 提交于 2021-02-11 15:40:43
问题 Steps to reproduce: Create a new Web API project Create a UsersController with the following code . [ApiController] [Route("[controller]")] public class UsersController : ControllerBase { [HttpGet("{id:int}", Name = nameof(GetUserByIdAsync))] public async Task<ActionResult<object>> GetUserByIdAsync([FromRoute] int id) { object user = null; return Ok(user); } [HttpPost] public async Task<ActionResult<object>> CreateUserAsync() { object user = null; return CreatedAtAction(nameof

On windows machine I get error : No matching manifest for windows/amd64

孤街醉人 提交于 2021-02-11 15:37:33
问题 I am new to docker , recently I have installed docker on my windows 10 machine(amd/64). But while using below link I am getting issues. https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images?view=aspnetcore-3.1 As per above link if I try to use image pull command : FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build I get below error : No matching manifest for windows/amd64 10.0.17134 in the manifest list entries I tried below steps to resolve this : 1.

Hello World for Powershell Send-XmlRcpRequest?

柔情痞子 提交于 2021-02-11 15:00:42
问题 Desired output something like: <?xml version="1.0"?> <methodResponse> <params> <param> <value><string>South Dakota</string></value> </param> </params> </methodResponse> How do I use the xml-rpc powershell module to view the response? Perhaps it's possible to "cat" or somehow pipe the result from baidu to something that will print it? Or, put it into an object? PS /home/nicholas/powershell> PS /home/nicholas/powershell> Send-XmlRpcRequest -Url "http://ping.baidu.com/ping/RPC2" -MethodName

How to redirect .ASPX pages to .NET Core Razor page

ぃ、小莉子 提交于 2021-02-11 14:57:32
问题 We are moving a big asp.net web site to .NET Core Razor pages site. All over the internet there are links that point to our site and we want those links to work after our migration. We will kept the same url format, but without the extension .aspx. Summary, we want our old url: example.com/item.aspx be handle by .net core razor page, as example.com/item 回答1: You could use the URL Rewriting Middleware to remove the ".aspx" extensions. Check the following code: Use AddRedirect to create a rule