我已将 OData 添加到我的 WebAPI 项目中。
版本:
这是我的startup.cs
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<Models.Contexts.EntityContext>(opts => opts.UseSqlServer(Configuration["ConnectionString:MailBackup"]));
services.AddControllers();
services.AddMvc(options =>
{
options.EnableEndpointRouting = false;
}).SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0);
services.AddOData();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc(routeBuilder =>
{
routeBuilder.EnableDependencyInjection();
routeBuilder.Expand().Select().OrderBy().Filter();
});
app.UseHttpsRedirection();
app.UseAuthorization();
}
}
Run Code Online (Sandbox Code Playgroud)
控制器是:
[EnableQuery()]
[HttpGet]
[Route("GetAll")]
public IQueryable<Models.EmailMessage> …Run Code Online (Sandbox Code Playgroud) 在使用 EF Core 5 的 .NET Core 5 WebAPI 项目中,我尝试对 LINQ 查询进行联合,但总是收到错误“无法翻译”。我试图连接的两个实体是相同的,并且字段定义的顺序也相同,所以我无法理解问题是什么以及为什么它不能转换为 SQL UNION:
IQueryable <MonthlyAggregatedPrice> monthlyAggregatedPrices =
(from map in db.MonthlyAggregatedPrices
where map.Adm0Code == adm0Code
orderby map.CommodityPriceDate descending
select map).Union(
from f in db.ST_PewiPriceForecasts
join cm in db.Commodities on f.CommodityID equals cm.CommodityID
join m in db.Markets on f.MarketID equals m.MarketId
join u in db.CommodityUnits on f.CommodityUnitID equals u.CommodityUnitID
join pt in db.PriceTypes on f.PriceTypeID equals pt.PriceTypeID
join cu in db.Currencies on f.CurrencyID equals cu.CurrencyID
where f.Adm0Code == adm0Code
select …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过缓存查询来提高Web应用程序的性能.
public static Func<myEntity, List<HASHDuplicates>, IQueryable<FormResponse>> CompiledDuplicatedResponses =
CompiledQuery.Compile<myEntity, List<HASHDuplicates>, IQueryable<FormResponse>>(
(db, hashes) => from r in db.FormResponse
from h in db.IndexHASHes
from d in hashes
where r.id == h.FormResponseID && h.IndexHASHString == d.hash
select r);
Run Code Online (Sandbox Code Playgroud)
我收到的错误是在编译时:
类型'myEntity'不能在泛型类型或方法'System.Data.Entity.Core.Objects.CompiledQuery.Compile(System.Linq.Expressions.Expression>)'中用作类型参数'TArg0'.没有从'myEntity'到'System.Data.Entity.Core.Objects.ObjectContext'的隐式引用转换.
我正在使用EF6
从今天早上开始,没有对项目代码进行任何更改,一个非常简单的Web API,一个控制器和3个方法(带有Swagger),它不再启动,并且出现错误:
HTTP错误500.35-同一进程中的ANCM多个进程内应用程序
事件查看器报告最无用的消息:
IIS Express AspNetCore模块V2:无法启动应用程序'/ LM / W3SVC / 2 / ROOT / docs',错误代码'0x80004005'。
重新启动系统几次。
我正在使用Visual Studio 2019,该应用程序已成功编译,几分钟前它运行良好。没有安装新软件,没有添加软件包。也尝试过清理和重建。
我刚刚修改了方法的注释。显然,我也尝试过恢复以前的评论,但总是收到相同的消息。
我能做什么?
网核是否仍然不稳定以致无法专业使用?
更新
从同一版本的Visual Studio启动的相同代码在另一台PC上正常运行。
更新2
在应用程序代码下方:
startup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using System;
using System.IO;
using System.Reflection;
namespace WFP_GeoAPIs
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", …Run Code Online (Sandbox Code Playgroud) 我正在尝试将TinyMCE 从 ver.4升级到 ver.5,但函数 file_browser_callback 已被替换为具有完全不同参数的file_picker_callback:
TinyMCE v.4
file_browser_callback: function (fieldId, value, type, win) {
browseFiles(value, type, function (fileUrl) {
win.document.getElementById(fieldId).value = fileUrl;
});
}
Run Code Online (Sandbox Code Playgroud)
TinyMCE v.5
file_picker_callback: function (callback, value, meta) {
browseFiles(value, meta.filetype, function (fileUrl) {
callback(fileUrl);
});
}
Run Code Online (Sandbox Code Playgroud)
我能仅取出旧的参数类型,在第5节是meta.filetype,而不是其他的参数,FIELD_NAME和赢,就要乐声FILEMAN。
这是我使用 v.4 的完整实现:
function initEditor(selector) {
tinymce.init({
selector: selector,
plugins: "paste,link,lists,advlist,image,table,contextmenu,media,fullscreen",
paste_as_text: true,
menubar: false,
language: 'en',
forced_root_block: 'div',
encoding: 'xml', …Run Code Online (Sandbox Code Playgroud) 我需要替换几年前构建的Flash查看器,以显示来自AutoCAD的交互式2D平面图。
当前,已读取AutoCAD文件并将其转换为XML文件,该文件包含表示平面图对象(房间,墙壁,资产等)的多边形的X和Y坐标。图形中的对象是可单击的,可以设置为可见或不取决于主题观点。
有时这些平面图可能相对较大,有很多要点。
我已经尝试使用像LeafletJS这样的Web地图控件,因为它已经具有PAN和ZOOM功能,我可以插入可点击的标记,并管理图层,以便可以通过主题视图显示或隐藏对象。我已将地图CRS设置为指标,并将数据加载为GeoJSON。不幸的是,对于现实世界的中型平面图,它太慢了,有时变得无响应。
下面的示例由18630线对象组成,平移时反应不是很大。
因此,现在我想使用SVG或CANVAS在浏览器中直接绘制平面图。我更喜欢使用CANVAS,因为它比SVG快得多,如果支持的话,也可以使用WebGL,但是我必须依靠一个库才能拥有事件处理程序和像DOM这样的简单对象管理。
因此,现在我要问的是,即使我需要映射2D对象并且这是选择正确的技术,像threeJS这样的库是否也可以轻松完成这样的任务。特别是,可以使用threeJS:
如果有人知道更好的库或技术可以完成此任务,那么我完全可以提出任何建议。
(请注意,我只需要2D工程图,因为已经使用Revit的其他技术构建了3D)
我已经在.Net Core 2.1中开发了一个简单的WEB API服务
我正在尝试实现客户端证书身份验证,因此我只能向在其计算机上安装了特定证书的客户端授予对API的访问权限。
客户端使用浏览器(Chrome,Edge,IE11或Firefox)访问API。
我在API方法中添加了对证书的请求:
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
X509Certificate2 cert = Request.HttpContext.Connection.ClientCertificate;
if (cert!=null && cert.Verify())
{
//more verification here...
return Content("....", "application/json");
}
else
{
return Content("....", "application/json");
}
}
Run Code Online (Sandbox Code Playgroud)
那么我已经安装了自签名证书,并将其添加到“受信任的根”中,从而启用了“客户端身份验证”目的。
但是变量cert始终为null,并且在我请求页面时浏览器甚至没有提示我使用证书。
我想是因为我必须在某个地方设置Web服务器必须要求客户端证书,因为可以在IIS中进行设置,但是在我的开发环境中,我使用的是IIS Express。
如何强制IIS Express请求客户端证书?
这是我使用任何 Visual Studio(2010 专业版、2012 专业版和 2015 社区版)的一周,几分钟后,我启动了一个项目,甚至是空的,没有接触任何东西,启动了一个完全消耗一个核心的线程,100% 使用率。从任务管理器中我看到devenv.exe消耗了 25% 的 CPU,我有 4 个核心,所以 100/4=25。
通过使用 Process Explorer,我看到clr.dll ( clr.dll!GetCLRFunction+10793 ) 正在连续运行。
这是线程的堆栈跟踪:
ntoskrnl.exe!KeWaitForMultipleObjects+0xc0a
ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel+0x712
ntoskrnl.exe!KeWaitForSingleObject+0x19f
ntoskrnl.exe!PoStartNextPowerIrp+0xba0
ntoskrnl.exe!PoStartNextPowerIrp+0x183d
ntoskrnl.exe!IoFreeErrorLogEntry+0x297
System.ni.dll+0x19ab70
System.ni.dll+0x1de979
System.ni.dll+0x19ab70
System.ni.dll+0x199d42
System.ni.dll+0x1ded86
System.ni.dll+0x1de5fa
System.ni.dll+0x1de397
System.ni.dll+0x1da636
System.ni.dll+0x1c755e
System.ni.dll+0x19ebfb
System.ni.dll+0x19eccf
clr.dll+0x1396
clr.dll+0x291f
clr.dll!PreBindAssemblyEx+0x1822c
clr.dll!PreBindAssemblyEx+0x183af
mscorlib.ni.dll+0x2f1213
mscorlib.ni.dll+0x2f103e
mscorlib.ni.dll+0x2ffb72
mscorlib.ni.dll+0x30a366
mscorlib.ni.dll+0x2ffd30
mscorlib.ni.dll+0x3aebef
mscorlib.ni.dll+0x3aeaba
clr.dll+0x291f
clr.dll+0x9aff
clr.dll!PreBindAssembly+0xb165
clr.dll!PreBindAssembly+0x9653
clr.dll!PreBindAssembly+0x96bd
clr.dll!PreBindAssembly+0x978a
clr.dll!PreBindAssembly+0x9805
clr.dll!PreBindAssembly+0xb0f9
clr.dll!PreBindAssembly+0xa166
clr.dll!GetCLRFunction+0x107dc
ntdll.dll!RtlInitializeExceptionChain+0x63
ntdll.dll!RtlInitializeExceptionChain+0x36
Run Code Online (Sandbox Code Playgroud)
有人从上面几行中明白了什么吗?
在互联网上,我发现了一些禁用 Visual Studio 的一个或另一个插件/扩展的建议,但没有一个解决了问题,而且我在所有 VS 版本上都有问题(具有不同的扩展并且同时发生)
我认为这与我最近更新的.net Framework 4.5 ~4.6有关。我怎样才能了解问题出在哪里以及如何解决?
我已将旧应用程序从 EF6 DB First 迁移到从现有数据库手动生成的上下文,并始终在 ASP.NET 4.7 上使用 EF6。
上下文定义如下:
namespace DataModel
{
using System;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
public partial class MyEntities : DbContext
{
public MyEntities()
: base("name=MyEntities")
{
}
public virtual DbSet<Country> Countries { get; set; }
public virtual DbSet<SomeNameSpace.Report> RE_Reports { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
类实体Report定义如下:
namespace DataModel
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
namespace SomeNameSpace
{
public partial class Report
{
[Key]
public int ReportID { get; …Run Code Online (Sandbox Code Playgroud) 我继承了一个应用程序,需要添加一个新功能,但现有数据库和应用程序的设计都很糟糕。
我需要使用 LINQ 查询提取所有员工及其文档数量以及已打开的文档数量。
为了对文档进行计数,我做了一个简单的操作count(),对于打开的数字,我有一个布尔字段,指示文档是否已打开。如果这个 lat 是一个值为 0 或 1 的整数,那就非常简单了,只需对该字段求和即可。
我也尝试使用布尔值来完成此操作,但失败了,因为我无法在 Linq-to-Entities 中使用 Convert.toInt32 :
var employees = from e in context.Employees
join d in context.EmployeeDocuments on e.EmployeeId equals d.EmployeeId into dj
from d in dj.DefaultIfEmpty()
group new { e, d } by new { e.EmployeeId, e.FirstName, e.LastName, e.FiscalCode, e.IdentificationNumber, e.EmploymentStartDate } into g
select new EmployeeListItem
{
EmployeeId = g.Key.EmployeeId,
FirstName = g.Key.FirstName,
LastName = g.Key.LastName,
FiscalCode = g.Key.FiscalCode,
IdentificationNumber = g.Key.IdentificationNumber,
EmploymentStartDate = g.Key.EmploymentStartDate.ToString("dd/MM/yyyy"),
DocumentCount …Run Code Online (Sandbox Code Playgroud) c# ×6
asp.net-core ×3
linq ×3
javascript ×2
.net ×1
.net-core ×1
asp.net ×1
caching ×1
canvas ×1
certificate ×1
html5 ×1
odata ×1
roxy-fileman ×1
svg ×1
three.js ×1
tinymce ×1