小编Ivo*_*gel的帖子

EF 7 - 新的 ExecuteDelete 和 ExecuteUpdate 方法不适用于内存数据库

我正在使用新的 EF 7ExecuteDeleteExecuteUpdate功能,它们非常棒。但是当我尝试为使用它们的函数编写单元测试时,这些测试崩溃了。

我在 .NET Core 7、7.0.1Microsoft.EntityFrameWorkCore.InMemory和 Xunit 2.4.2上使用 EF 7.0.1

[Fact]
public async Task DeleteAccountAsync__Success()
{
    var accountId = Guid.Parse("52ff9d4e-efb9-4b51-b5e7-1734d10187f7");

    // CRASH
    _context.Accounts
            .Where(p => p.AccountId == accountId)
            .ExecuteDelete();
}

private void SeedDataBase()
{
    var a1 = new Account
        {
            AccountId = Guid.Parse("52ff9d4e-efb9-4b51-b5e7-1734d10187f7"),
        };

    var a2 = new Account
        {
            AccountId = Guid.Parse("d5c38300-0de6-4118-8d01-6bc94842d4b5"),
        };

    _context.Accounts.AddRange(a1, a2);
    _context.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

消息“无法翻译 LINQ 表达式 'DbSet()\n .Where(a => a.AccountId == __accountId_0)\n .ExecuteDelete()'。请以可翻译的形式重写查询,或者切换通过插入对“AsEnumerable”、“AsAsyncEnumerable”、“ToList”或“ToListAsync”的调用来显式进行客户端评估。有关详细信息,请参阅 https://go.microsoft.com/fwlink/?linkid=2101038。

c# in-memory-database entity-framework-core .net-7.0 ef-core-7.0

14
推荐指数
1
解决办法
4444
查看次数

MVC视频流到移动Web浏览器

嗨,大家好,我想通过ASP.NET MVC Web应用程序将视频从我的Azure blob流式传输到桌面浏览器上的用户,当然还有移动浏览器.

到目前为止我构建的是一个ASP.NET MVC应用程序,它为网站提供服务,而WebApi服务则是PushStreamContent.这在桌面上的Chrome和Edge上非常棒.但是,我试图在移动设备Chrome,Safari,Firefox上打开它,它就不会玩了.

我的代码到目前为止:

关于MVC项目的观点

<video id="vPlayer" class="video-js" autoplay controls playsinline preload="auto" data-setup='{"fluid": true}'poster="@ImgManager.GetVideoImgUrl(Model.ThumbnailUrl)">
<source src="//xyz.nl/api/Videos/Get?filename=340a85a3-ccea-4a2a-bab6-74def07e416c.webm&type=video%2Fwebm" type="video/webm">
<source src="//xyz.nl/api/Videos/Get?filename=340a85a3-ccea-4a2a-bab6-74def07e416c.mp4&type=video%2Fmp4" type="video/mp4">
Run Code Online (Sandbox Code Playgroud)

WebApi

public HttpResponseMessage Get(string filename, string type)
        {
            var video = new VideoStream(filename);
            var response = Request.CreateResponse();

            response.Content = new PushStreamContent(video.WriteToStream, new MediaTypeHeaderValue(type));

            return response;
        }
Run Code Online (Sandbox Code Playgroud)

webAPI上的助手

public class VideoStream
    {
        private readonly string _filename;

        public VideoStream(string fileName)
        {
            _filename = fileName;
        }



        public async Task WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
        {
            try
            {
                var storage …
Run Code Online (Sandbox Code Playgroud)

c# asp.net model-view-controller video-streaming asp.net-web-api

5
推荐指数
1
解决办法
528
查看次数