我对存储过程很新.
假设我有一个IDCategory(int)并将其传递给存储过程.在正常谈话中,它会:
找到我所有的IDCategory列表等于我告诉你要找的IDCategory.
所以它会找到说3列表,并创建一个包含列的表:
IDListing,IDCategory,Price,Seller,Image.
我怎么能实现这个目标?
将我们的 blazor 应用程序部署到 azure 时,它五分之四失败并出现此错误(从 chrome 开发工具复制):
[2019-12-16T11:12:55.214Z] Information: Normalizing '_blazor' to 'https://example.com/_blazor'.
[2019-12-16T11:12:55.470Z] Information: WebSocket connected to wss://example-web-signalr-service.service.signalr.net/client/?hub=componenthub&asrs.op=%2F_blazor&negotiateVersion=1&asrs_request_id=...&id=...&access_token=...
[2019-12-16T11:12:55.548Z] Error: The list of component records is not valid.
e.log @ blazor.server.js:15
C @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:1
e.invokeClientMethod @ blazor.server.js:1
e.processIncomingData @ blazor.server.js:1
connection.onreceive @ blazor.server.js:1
i.onmessage @ blazor.server.js:1
[2019-12-16T11:12:55.552Z] Information: Connection disconnected.
Uncaught (in promise) Error: Invocation canceled due to the underlying connection being closed.
at e.connectionClosed (blazor.server.js:1)
at e.connection.onclose (blazor.server.js:1)
at e.stopConnection (blazor.server.js:1)
at …Run Code Online (Sandbox Code Playgroud) azure .net-core azure-web-app-service blazor blazor-server-side
我想使用Caching.Cache(...)方法,如下所示:
Cache.Insert("Interview Questions", datatable, sqlcachedep)
Run Code Online (Sandbox Code Playgroud)
要么
System.Web.Caching.Cache.Insert("Reading List", datatable, sqlcachedep);
Run Code Online (Sandbox Code Playgroud)
变量没有问题,但在任何一种情况下都会收到此错误消息:
错误1 - 非静态字段,方法或属性'System.Web.Caching.Cache.Insert(string,object,System.Web.Caching.CacheDependency)'需要对象引用
我怎样才能解决这个问题?
谢谢
我一直在寻找一些技巧来提高我的实体框架查询性能,并偶然发现了这篇有用的文章。
这篇文章的作者提到了以下几点:
08 避免使用 contains
在 LINQ 中,我们使用 contains 方法来检查是否存在。它在 SQL 中被转换为“WHERE IN”,这会导致性能下降。
我还有哪些更快的替代方案?
我正在努力在 Blazor 服务器的类中注入服务 (AuthenticationStateProvider)。如果我在剃刀组件中执行此操作,则非常简单:
@inject AuthenticationStateProvider AuthenticationStateProvider
进而
private async Task LogUsername()
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
ClientMachineName = $"{user.Identity.Name}";
}
else
{
ClientMachineName = "Unknown";
}
}
Run Code Online (Sandbox Code Playgroud)
但是我需要这样做,即在类中而不是在剃刀组件中检索经过身份验证的用户机器名称。
我试过例如:
[Inject]
AuthenticationStateProvider AuthenticationStateProvider { get; set; }
public async Task LogUsername()
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
ClientMachineName = $"{user.Identity.Name}";
}
else
{
ClientMachineName = "Unknown";
}
}
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用。
任何帮助将非常感激。
我正在尝试实现https://learn.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-3.1#work-with-radio中找到的“使用单选按钮”示例-buttons然而,当我尝试将它与枚举一起使用时遇到了困难。
@page "/RadioButtonExample"
@using System.ComponentModel.DataAnnotations
@using MyApp.Shared
<h1>Radio Button Group Test</h1>
<EditForm Model="model" OnValidSubmit="HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
@foreach (int status in Enum.GetValues(typeof(Status)))
{
<label>
<InputRadio name="rate" SelectedValue="status" @bind-Value="model.Status" />
@status
</label>
}
<button type="submit">Submit</button>
</EditForm>
<p>You chose: @model.Status</p>
@code {
private Administrator model = new Administrator();
private void HandleValidSubmit()
{
Console.WriteLine("valid");
}
}
Run Code Online (Sandbox Code Playgroud)
我的枚举定义如下
public enum Status
{
Disabled = 0,
Enabled = 1
}
Run Code Online (Sandbox Code Playgroud)
我收到的错误如下,我明白为什么会出现这种情况,但是,我不确定如何最好地解决。
TypeInference.CreateInputRadio_0(RenderTreeBuilder, int, int, object, int, TValue, int, TValue, int, EventCallback, int, …
我使用GMap添加了一个标记,指定了lat/long.当应用程序启动时,标记放置在错误的位置(在GMap控件的中心),然后当我缩放时,它将转到指定的坐标.这是GMap中的错误还是我做错了什么?这是代码.
GMapOverlay markersOverlay, mo2;
GMarkerGoogle marker, marker5;
GMapOverlay polyOverlay;
List<PointLatLng> points;
GMapRoute gr;
Graphics g;
bool start = true;
double move = .0001;
double lt = 73, lg = -180;
public Form1()
{
AllocConsole();
InitializeComponent();
try
{
System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("www.google.com");
}
catch
{
gmap.Manager.Mode = AccessMode.CacheOnly;
MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET - Demo.WindowsForms", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
gmap.MapProvider = GMapProviders.BingHybridMap;
gmap.Position = new PointLatLng(32, -100);
gmap.MinZoom = 3;
gmap.MaxZoom = 15;
gmap.Zoom = 9;
markersOverlay = …Run Code Online (Sandbox Code Playgroud) 我试图阻止用户DataGrid在使用内置的 .NET DataGridAddNewItem 功能时添加空行。因此,当用户尝试提交 的 AddNew 事务DataGrid并PageItemViewModel.Text留空时,它应该从DataGrid.
ViewModels
public class PageItemViewModel
{
public string Text { get; set; }
}
public class PageViewModel
{
public ObservableCollection<PageItemViewModel> PageItems { get; } = new ObservableCollection<PageItemViewModel>();
}
Run Code Online (Sandbox Code Playgroud)
View
<DataGrid AutoGenerateColumns="True"
CanUserAddRows="True"
ItemsSource="{Binding PageItems}" />
Run Code Online (Sandbox Code Playgroud)
...在处理时从DataGrid's 中删除自动创建的对象ItemsSource:
DataGrid.AddingNewItemINotifyCollectionChanged.CollectionChanged 的 PageViewModel.PageItemsIEditableCollectionView.CancelNewDataGrid.OnItemsChanged...但总是收到如下异常:
- " System.InvalidOperationException:在 AddNew 或 EditItem 事务期间不允许 'Removing'。"
- “ System.InvalidOperationException:无法在 CollectionChanged 事件期间更改 ObservableCollection。” …
我创建了一个“剃刀组件”项目。我正在尝试在按下按钮时执行异步方法,但仍无法弄清楚语法。
这是我的Index.razor:
@page "/"
@inject GenericRepository<Person> PersonRepository
// ...
@foreach (var person in persons)
{
<button onclick="@(() => Delete(person.Id))">?</button>
}
@functions {
// ...
async void Delete(Guid personId)
{
await this.PersonRepository.Delete(personId);
}
}
Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,什么也没有发生。我尝试了各种返回类型(例如Task)和东西,但无法弄清楚如何使其工作。如果需要提供更多信息,请告诉我。
每个文档/教程仅在按钮单击时仅适用于非异步void调用。
提前致谢。
我需要访问一些 Google API(通过Google.Apis.*NuGet 包)。因此我需要按照官方文档Google.Apis.Auth.AspNetCore中的描述使用该包
:
services
.AddAuthentication(o =>
{
o.DefaultChallengeScheme = GoogleOpenIdConnectDefaults.AuthenticationScheme;
o.DefaultForbidScheme = GoogleOpenIdConnectDefaults.AuthenticationScheme;
o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddGoogleOpenIdConnect(options =>
{
options.ClientId = googleClientId;
options.ClientSecret = googleClientSecret;
});
Run Code Online (Sandbox Code Playgroud)
另一方面,我使用经典的 ASP.NET Core Identity,特别是
使用
NuGet 包的Google 外部登录设置Microsoft.AspNetCore.Authentication.Google,其初始化如下:
services
.AddAuthentication()
.AddGoogle(options =>
{
options.ClientId = googleClientId;
options.ClientSecret = googleClientSecret;
});
Run Code Online (Sandbox Code Playgroud)
有没有办法共享 OAuth 配置、登录……?这两个包都使用自己的 OAuth 初始化代码...我在调用 和 时会遇到问题AddGoogle()吗AddGoogleOpenIdConnect()?
c# google-api google-oauth google-api-dotnet-client asp.net-core
c# ×7
blazor ×4
razor ×2
sql ×2
.net-core ×1
asp.net-core ×1
azure ×1
datagrid ×1
gmap.net ×1
google-api ×1
google-oauth ×1
linq ×1
performance ×1
t-sql ×1
wpf ×1