@_openTag
@* content *@
@_closeTag
@code {
private MarkupString _openTag;
private MarkupString _closeTag;
}
@andrewleith An option would be this primitive component, where you can pass whatever html element you want through the HtmlTag property
public class Element:ComponentBase
{
[Parameter] public RenderFragment ChildContent { get; set; }
public Dictionary<string, object> UserAttributes { get; set; } = new Dictionary<string, object>();
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
builder.OpenElement(0, HtmlTag);
builder.AddMultipleAttributes(1, UserAttributes);
builder.AddContent(2, ChildContent);
builder.CloseElement();
}
}
So you can use it like
<Element HtmlTag="div" class="my-class" > <div> Child Content</div> </Element>
<div class="my-class"> <div> Child Content</div> </div>
modelBuilder.Entity<Project>().HasMany(p => p.Tags).WithMany(t => t.Projects);
and that seems to work fine. Now, I want to add a new entity called ProjectTagHighlight, which need to have an Id, ProjectId, TagId and a text column. How do I set this up properly, because I don't have a ProjectTag model in my code
This question isn't really ASP.NET Core-related, but I asked it a week ago in the corefx channel and no one answered:
I have a System.Text.Json problem. I recently upgraded my API code to .NET 5, and I'm looking into converting the serialization provider from JSON.NET to System.Text.Json. Standard serialization/deserialization works fine, but I'm having trouble converting a particular pattern.
In my API I have a few places where I distinguish between null inputs and undefined in the input JSON. Specifically, null means "remove this value" and undefined means "keep this value as it is".
The way I've implemented this is with the approach described here: https://github.com/alberto-chiesa/SettableJsonProperties. I have a type Optional<T> which distinguishes between null and undefined, an OptionalJsonConverter which converts literal null properties to null and omitted properties to undefined, and a custom contract resolver that relies on the ShouldSerialize-metod, as described here: https://github.com/alberto-chiesa/SettableJsonProperties/blob/master/SettableContractResolver.cs.
STJ doesn't have custom contract resolvers (dotnet/runtime#31257, dotnet/runtime#36785 ), nor any sort of equivalent of the "ShouldSerialize" pattern, as far as I can tell. I can't figure out a decent workaround, so I'm basically stuck here. Has anyone else done anything similar?
Hello there,
I have a web browser extension app that talks to ASP.NET core 3.1 web API. Every conversation between them must include a file (around 100kb or so). Currently, the file is a base64 string within HTTP post JSON requests. Upon receiving the file, the API converts it into a file on the server and updates and sends it back. This approach was the fastest way for me to implement it. The problem with this approach is now it appears slow under stress tests. Any suggestions on making them talk faster?