我试图找到一种方法来递归地从XmlNode获取子节点的总数.
这就是说我想算所有孩子,大孩子等.
我觉得它有点像
node.SelectNodes(<fill in here>).Count
Run Code Online (Sandbox Code Playgroud)
但我不知道XPath是什么.
我很确定我知道答案是否定的,但作为最后的尝试,我想我会问这里的问题.
我首先使用EF代码以通常的方式查询表
_context.Set<Foo>().Where(f => f.Bar == 999);
Run Code Online (Sandbox Code Playgroud)
这会创建以下表达式(我刚刚写了这个,所以它可能是错的).
{SELECT
[Extent1].[Test] AS [Test],
[Extent1].[Test2] AS [Test2],
FROM [dbo].[Foo] AS [Extent1]
WHERE 19 = [Extent1].[Bar]}
Run Code Online (Sandbox Code Playgroud)
现在,是否可以手动修改此查询以将表名更改为,例如,Foo10?(可能不是)
如果不这样做,是否有人知道我可以先在代码中"延迟绑定"表名的方式?
你可能想知道"为什么肮脏的黑客?" 像往常一样,这是一个遗留问题,数据库存在一些设计问题,无法更改.
提前致谢.
PS.我知道我可以使用Database.SqlQuery但不愿意.
我已经开始考虑在 EventStore 中使用 Reactive Extensions。作为概念证明,我想看看我是否可以让 Rx 使用事件流并输出按类型分组的事件计数一秒钟的窗口。
因此,假设我正在使用名为“orders”的流,我希望在控制台中看到如下所示的内容:
OrderCreated 201
OrderUpdated 111
Run Code Online (Sandbox Code Playgroud)
(一秒钟过去了..)
OrderCreated 123
OrderUpdated 132
Run Code Online (Sandbox Code Playgroud)
等等。
到目前为止,我已经能够获得每秒所有事件计数的输出。但似乎无法按事件类型对它们进行分组。
我使用的代码基于James Nugent 的一个要点:
internal class EventStoreRxSubscription
{
public Subject<ResolvedEvent> ResolvedEvents { get; }
public Subject<SubscriptionDropReason> DroppedReasons { get; }
public EventStoreSubscription Subscription { get; }
public EventStoreRxSubscription(EventStoreSubscription subscription, Subject<ResolvedEvent> resolvedEvent, Subject<SubscriptionDropReason> droppedReasons)
{
Subscription = subscription;
ResolvedEvents = resolvedEvent;
DroppedReasons = droppedReasons;
}
}
static class EventStoreConnectionExtensions
{
public static Task<EventStoreRxSubscription> SubscribeTo(this IEventStoreConnection connection, string streamName, bool …Run Code Online (Sandbox Code Playgroud) 背景
我在一个项目中使用 EventStore(来自geteventstore.com)。到目前为止,我已经实现了应用程序的写入端。也就是说,我可以读取和写入给定聚合的事件。
现在我在阅读方面,需要订阅一个流。我正在使用 java api,一切都在这里工作。
现在的问题
流不存在......我必须创建一个投影,将来自不同流的事件聚合到我的读取模型的单个流中。
如何通过 api 创建投影?最好使用 java api,但 http api 也可以。
细化
由于预测是 readmodel 获取其需要的确切事件的手段,因此随着业务需求的变化,将创建新的预测。因此,我的想法是 readmodel 服务将在启动时检查并可能创建它需要的投影。
在启动服务之前手动创建投影是不可接受的。这就像手动迁移您的 sql 数据库。
嘿,所以我遇到了这样一种情况,即我将客户从数据库中拉回来并通过包含所有案例研究
return (from c in db.Clients.Include("CaseStudies")
where c.Id == clientId
select c).First();
Run Code Online (Sandbox Code Playgroud)
但我现在要做的是和所包含的casestudies的where子句,以便它只返回案例研究,其中deleted = false
有点像这样
return (from c in db.Clients.Include("CaseStudies")
where c.Id == clientId
&& c.CaseStudy.Deleted == false
select c).First();
Run Code Online (Sandbox Code Playgroud)
但这不起作用:(任何想法
我想在更新记录时阻止两个用户意外地覆盖彼此.也就是说两个用户加载一个带有记录A的页面.用户1将记录更新为AB,用户2将其更新为AC.
我不只是想让最后一个命中数据库来覆盖.我需要一种机制来说明记录已经更新,因此你的记录无法保存.
现在我的两个想法是给记录加盖时间戳并检查.如果不匹配则不允许更新.第二种方法是每次执行更新时GUID记录,检查GUID以及它是否不匹配不更新.
这些方法中的任何一种都是有效的,如果是的话,这是最好的.如果没有,你有什么建议.这是在C#中,如果它有所作为
谢谢
所以,如果我的数据库中有一个包含值的表
1
2
3
4
NULL
Run Code Online (Sandbox Code Playgroud)
我执行了查询
SELECT MAX(col1) FROM <table>
Run Code Online (Sandbox Code Playgroud)
我得到4.有没有办法改变这个,所以Null会被视为最大值,而不是最小值?
谢谢!
忽略这可能不是一个好主意的事实是有可能让requirejs使用两个不同的路径引用一个库,即
require.config({
paths: {
'ko': '../Lib/knockout-2.1.0.debug',
'knockout': '../Lib/knockout-2.1.0.debug',
}
});
Run Code Online (Sandbox Code Playgroud)
或者可能是其他方式?目前正在抱怨
原因是我们有一些外部库在'淘汰'上具有外部依赖性,因为我们使用'ko'
作为GetEventStore的第一次用户并阅读了文档,我遇到了一个问题,即事件从未出现在我的订阅客户端上。
由于我错过了一个配置步骤,这是可能的。
拥有此控制台应用程序客户端:
public class EventStoreSubscriptionClient : ISubscriptionClient
{
private const string GroupName = "liner";
private const string StreamName = "$ce-happening";
private readonly IProvideEventStoreConnection _eventStoreConnection;
private readonly UserCredentials _userCredentials;
private EventStorePersistentSubscriptionBase EventStorePersistentSubscriptionBase { get; set; }
public EventStoreSubscriptionClient(IProvideEventStoreConnection eventStoreConnection, UserCredentials userCredentials)
{
_eventStoreConnection = eventStoreConnection;
_userCredentials = userCredentials;
}
public void Connect()
{
var connection = _eventStoreConnection.ConnectAsync().Result;
EventStorePersistentSubscriptionBase = connection.ConnectToPersistentSubscription(
StreamName,
GroupName,
EventAppeared,
SubscriptionDropped,
_userCredentials,
10,
false
);
}
private void SubscriptionDropped(EventStorePersistentSubscriptionBase subscription, SubscriptionDropReason reason, Exception ex)
{ …Run Code Online (Sandbox Code Playgroud) 我已经设置了Event Store,并且可以愉快地将事件写入流、订阅和读取历史事件,一切正常。
我可以看到ResolvedEvent传递给我的订阅处理程序方法的那个有一个Link属性,但我想知道当我写入流时,我如何“设置”这个属性?
我尝试设置各种元数据属性(使用 JSON 表示法),查看源代码,但没有找到任何有效的方法。
我可能会以错误的方式解决这个问题,以及我正在尝试做的事情(将事件写入流,然后将第二个事件链接到第一个事件,以便稍后我可以找到“回复”)应该以另一种方式完成。
c# ×6
eventstoredb ×4
code-first ×1
cqrs ×1
database ×1
http ×1
include ×1
iqueryable ×1
java ×1
javascript ×1
linq ×1
max ×1
null ×1
overwrite ×1
requirejs ×1
rx.net ×1
sql ×1
where-clause ×1
xml ×1
xpath ×1