对于未来的访问者:对于EF6,您可能最好使用过滤器,例如通过此项目:https://github.com/jbogard/EntityFramework.Filters
在我们正在构建的应用程序中,我们应用"软删除"模式,其中每个类都有一个'已删除'布尔.实际上,每个类都只是继承自这个基类:
public abstract class Entity
{
public virtual int Id { get; set; }
public virtual bool Deleted { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
举一个简短的例子,假设我有类GymMember和Workout:
public class GymMember: Entity
{
public string Name { get; set; }
public virtual ICollection<Workout> Workouts { get; set; }
}
public class Workout: Entity
{
public virtual DateTime Date { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当我从数据库中获取健身房成员列表时,我可以确保没有获取任何"已删除"健身房成员,如下所示:
var gymMembers = context.GymMembers.Where(g => !g.Deleted);
Run Code Online (Sandbox Code Playgroud)
然而,当我遍历这些健身房成员时,他们Workouts从数据库加载而不考虑他们的Deleted旗帜.虽然我不能责怪实体框架没有理解这一点,但我想以某种方式配置或拦截延迟属性加载,以便永远不会加载已删除的导航属性.
我一直在考虑我的选择,但它们看起来很稀缺: …
这个问题有点类似于这个,但我想知道是否有一个与Bootstrap兼容的纯CSS解决方案.
基本上,我有以下布局:

这是该页面的HTML:
<div class="menu row">
<div class="menu-category list-group col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="menu-category-name list-group-item active">Category</div><a href="#" class="menu-item list-group-item">Lorem ipsum.<span class="badge">€ 0.00</span></a>
<a href="#" class="menu-item list-group-item">Lorem ipsum.<span class="badge">€ 0.00</span></a>
<a href="#" class="menu-item list-group-item">Lorem ipsum.<span class="badge">€ 0.00</span></a>
<a href="#" class="menu-item list-group-item">Lorem ipsum.<span class="badge">€ 0.00</span></a>
<a href="#" class="menu-item list-group-item">Lorem ipsum.<span class="badge">€ 0.00</span></a>
<a href="#" class="menu-item list-group-item">Lorem ipsum.<span class="badge">€ 0.00</span></a>
<a href="#" class="menu-item list-group-item">Lorem ipsum.<span class="badge">€ 0.00</span></a>
</div>
<div class="menu-category list-group col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="menu-category-name list-group-item active">Category</div><a href="#" …Run Code Online (Sandbox Code Playgroud) 我有一个observable,它代表一个由一些外部组件触发的动作.出于这个问题的目的,我们称之为createBananaAction.我有一个bananaService方法create执行一个AJAX请求并返回创建的香蕉作为Promise.
因此,每当有一些数据从createBananaAction我们到达时,我们都想打电话bananaService.create().
代码如下所示:(使用RxJs)
this.createdBananas = createBananaAction.flatMap(() => bananaService.create());
Run Code Online (Sandbox Code Playgroud)
现在,挑战是"限制"createBananaAction,以便它只能在收到前一个香蕉后请求另一个香蕉.简单地说:永远不会有两个同时来电bananaService.create().请注意,我不想及时限制,而是在bananaService执行其操作时忽略所有传入的新香蕉请求.
我做了一些研究,找到了看似合适的pausable操作员.
我的代码现在看起来像这样:
const pausableCreateBananaAction = createBananaAction.pausable();
this.createdBananas = pausableCreateBananaAction
.do(() => pausableCreateBananaAction.pause())
.flatMap(() => bananaService.create())
.do(() => pausableCreateBananaAction.resume());
Run Code Online (Sandbox Code Playgroud)
这似乎有效,但我不喜欢我需要这些do语句来手动触发pause和resume语句的事实.
我发现,你可以通过一个可观察到pausable那么应该产生false或true在适当的时间,但是这也需要我在受到手动推值.像这样的东西:
const letItGoThrough = new Rx.Subject();
this.createdBananas = createBananaAction
.pausable(letItGoThrough.startWith(true))
.do(() => letItGoThrough.onNext(false))
.flatMap(() => bananaService.create())
.do(() => letItGoThrough.onNext(true));
Run Code Online (Sandbox Code Playgroud)
所以现在我有了一个Rx.Subject(主题就像是RxJs的训练轮,你使用的是直到你在RxJs上经验不足而你不再需要它们.)和两次调用do. …
我已经在 .NET(框架和核心)领域工作多年了,我希望将 .NET Framework 应用程序移植到 .NET Core。
在此 .NET Framework 应用程序中,我们有 .resx 文件,其中包含数千个标签,并翻译为 5 种语言。这些 .resx 文件已生成 C# 源代码,使我们能够以类型安全的方式静态访问它们。这样做时会尊重当前的 UI 文化。
当我查找 .NET Core 中的本地化文档(可在此处找到)时,游戏规则发生了巨大变化:
我是唯一一个认为这比 .NET Framework 中的内容复杂得多且不必要的人吗?我能理解ILocalizer和朋友们从哪里来的,因为现在一切都需要经过依赖注入。但是魔法弦呢?Resx 文件到处都是?
老实说,.NET Core 的底层机制一直给我留下了深刻的印象,但本地化方面却让我完全不知所措。有没有人可以针对这个问题提供可靠、有效的解决方案?拥有类型安全标签可能是我的第一要求。
提前致谢!
编辑:这是具有更好格式的赏金消息:
我正在寻找 C# 本地化解决方案
如果这些要求的唯一解决方案是现有的 .resx 工作流程,那么我也会接受来自官方文档的权威答案或来自 Microsoft 内部权威人士的声明,其中明确提到带有生成的 C# 代码的资源文件是可接受的,支持 ILocalizer 故事的替代方案。
我正在尝试将 protobuf-net 与 C# 位置记录类型一起使用,但我遇到了这个异常:
10:18:48.048 [EROR] #010 (Microsoft.AspNetCore.Server.Kestrel) Connection id ""0HM4NDHMUB3C6"", Request id ""0HM4NDHMUB3C6:00000003"": An unhandled exception was thrown by the application.
Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. ProtoException: No parameterless constructor found for Bidirectional.Demo.Common.Contracts.Server.GetServerProcessI
nfo.GetServerProcessInfoResponse", DebugException="ProtoBuf.ProtoException: No parameterless constructor found for Bidirectional.Demo.Common.Contracts.Server.GetServerProcessInfo.GetServerProcessInfoResp
onse
at ProtoBuf.Internal.ThrowHelper.ThrowProtoException(String message, Exception inner) in /_/src/protobuf-net.Core/Internal/ThrowHelper.cs:line 70
at ProtoBuf.Meta.TypeModel.ThrowCannotCreateInstance(Type type, Exception inner) in /_/src/protobuf-net.Core/Meta/TypeModel.cs:line 1666
at proto_12(State& , GetServerProcessInfoResponse )
at ProtoBuf.Internal.Serializers.SimpleCompiledSerializer`1.ProtoBuf.Serializers.ISerializer<T>.Read(State& state, T value)
at ProtoBuf.ProtoReader.State.ReadAsRoot[T](T value, ISerializer`1 serializer)
at ProtoBuf.ProtoReader.State.DeserializeRoot[T](T value, ISerializer`1 …Run Code Online (Sandbox Code Playgroud) c# ×3
javascript ×2
asp.net-core ×1
css3 ×1
html ×1
jquery ×1
localization ×1
protobuf-net ×1
rxjs ×1
soft-delete ×1
throttling ×1