Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 15 02:42
    natalie-perret-1986 commented #1283
  • Jun 15 02:42
    natalie-perret-1986 commented #1283
  • Jun 14 16:03
    dariogriffo edited #1843
  • Jun 14 16:03
    dariogriffo edited #1843
  • Jun 14 08:18
    dnfadmin commented #1843
  • Jun 14 08:18
    dnfadmin commented #1843
  • Jun 14 08:17
    dnfadmin commented #1843
  • Jun 14 08:17
    dnfadmin commented #1843
  • Jun 14 08:17
    dariogriffo opened #1843
  • Jun 14 08:17
    dariogriffo opened #1843
  • Jun 09 11:26
    VilleHakli edited #1842
  • Jun 09 11:26
    VilleHakli edited #1842
  • Jun 09 07:55
    VilleHakli opened #1842
  • Jun 09 07:55
    VilleHakli opened #1842
  • Jun 08 04:54

    mysticmind on master

    Bump up version to rc.2 (compare)

  • Jun 08 04:54

    mysticmind on master

    Bump up version to rc.2 (compare)

  • Jun 04 21:25

    jeremydmiller on master

    deleted some tests that are dup… (compare)

  • Jun 04 21:25

    jeremydmiller on master

    deleted some tests that are dup… (compare)

  • Jun 04 20:58
    jeremydmiller commented #1840
  • Jun 04 20:58
    jeremydmiller commented #1840
Jeremy D. Miller
@jeremydmiller
You can always drop to pure SQL
And that’s our lame copout in these situations, except that it does work
Thumann
@Thumann
Can I make a SQL view and access that through marten? Or completely bypass marten for this functionality ?
Jeremy D. Miller
@jeremydmiller
Little easier to bypass Marten, but you can get at the connection for a session if you want. IQuerySession.Connection (and IDocumentSession implements IQuerySession too
Thumann
@Thumann
I meant 'session.Query<AlarmOverview>("mycrazyview")'
Jeremy D. Miller
@jeremydmiller
Ah, no, sorry
Thumann
@Thumann
got it :) custom for now it is!
JT
@Hawxy
Hello, any chance of a new alpha release? There's a few fixes in master we require :).
Babu Annamalai
@mysticmind
@Hawxy we will push out a release today :-)
1 reply
Babu Annamalai
@mysticmind
@/all 4.0.0-alpha.10 is available in NuGet
MinhMit
@MinhMit
hello supporter, i use version 4.0.0 alpha 9 and i receive error:
at LamarCompiler.AssemblyGenerator.Generate(String code)
at LamarCompiler.AssemblyGenerator.Compile(GeneratedAssembly generatedAssembly, IServiceVariableSource services)
at Marten.Events.Aggregation.AggregateProjection1.Compile(StoreOptions options) at Marten.Events.Aggregation.AggregateProjection1.Build(DocumentStore store)
at Marten.Events.Projections.ProjectionCollection.<>cDisplayClass10_0.<BuildInlineProjections>b1(ProjectionSource x)
at System.Linq.Enumerable.WhereSelectListIterator2.ToArray() at Marten.Events.Projections.ProjectionCollection.BuildInlineProjections(DocumentStore store) at Marten.Events.EventGraph.<.ctor>b__8_2() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy1.CreateValue() at Marten.Events.EventGraph.<ProcessEventsAsync>d__70.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Marten.Internal.Sessions.DocumentSessionBase.<SaveChangesAsync>d__61.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Iot.Core.Infrastructure.Repositories.Implements.EventStoreRepository1.<StartStreamAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Compilation failures!
CS1003: Syntax error, ',' expected
CS1003: Syntax error, ']' expected
CS1003: Syntax error, ',' expected
CS1003: Syntax error, ',' expected
CS1026: ) expected
CS1002: ; expected
CS1513: } expected
CS1003: Syntax error, ',' expected
CS1002: ; expected
CS1002: ; expected
CS1002: ; expected
CS1003: Syntax error, ',' expected
CS1002: ; expected
CS1010: Newline in constant
CS1002: ; expected
CS1003: Syntax error, ',' expected
CS1003: Syntax error, ']' expected
CS1003: Syntax error, ',' expected
CS1003: Syntax error, ',' expected
CS1026: ) expected
CS1002: ; expected
CS1513: } expected
CS1003: Syntax error, ',' expected
CS1002: ; expected
CS1002: ; expected
CS1002: ; expected
CS1003: Syntax error, ',' expected
CS1002: ; expected
CS1010: Newline in constant
CS1002: ; expected
CS0246: The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)
CS0021: Cannot apply indexing with [] to an expression of type 'int'
CS0841: Cannot use local variable 'Iot' before it is declared
CS0841: Cannot use local variable 'Iot' before it is declared
CS0103: The name 'Version' does not exist in the current context
CS0103: The name 'Culture' does not exist in the current context
CS0103: The name 'neutral' does not exist in the current context
CS0103: The name 'PublicKeyToken' does not exist in the current context
CS0246: The type or namespace name 'or' could not be found (are you missing a using directive or an assembly reference?)
CS0246: The type or namespace name 'Replayer' could not be found (are you missing a using directive or an assembly reference?)
CS0246: The type or namespace name 'have' could not be found (are you missing a using directive or an assembly reference?)
CS0246: The type or namespace name 'Default' could not be found (are you missing a using directive or an assembly reference?)
CS0246: The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)
CS0021: Cannot apply indexing with [] to an expression of type 'int'
CS0103: The name 'Version' does not exist in the current context
CS0103: The name 'Culture' does not exist in the current context
CS0103: The name 'neutral' does not exist in the current context
CS0103: The name 'PublicKeyToken' does not exist in the current context
CS0246: The type or namespace name 'or' could not be found (are you missing a using directive or an assembly reference?)
CS0128: A local variable or function named 'Iot' is already defined in this scope
CS0246: The type or namespace name 'Replayer' could not be found (are you missing a using directive or an assembly reference?)
CS0128: A local variable or function named 'should' is already defined in this scope
CS0246: The type or namespace name 'have' could not be found (are you missing a using directive or an assembly reference?)
CS0128: A local variable or function named 'a' is already defined in this scope
CS0246: The type or namespace name 'Default' could not be found (are you missing a using directive or an assembly reference?)
CS0128: A local variable or function named 'Constructor' is already defined in this scope

Code:

using Marten;
using Marten.Events.Aggregation;
using Marten.Internal.Storage;
using Marten.Storage;
using System.Linq;

namespace Marten.Generated
{
// START: AggregateProjection_Iot_Replayer_Domain_Aggregates_VideoAggregateRoot_LiveAggregation
public class AggregateProjection_Iot_Replayer_Domain_Aggregates_VideoAggregateRoot_LiveAggregation : Marten.Events.Aggregation.SyncLiveAggregatorBase<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot>
{
private readonly Marten.Events.Aggregation.AggregateProjection<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot> _aggregateProjection;

    public AggregateProjection_Iot_Replayer_Domain_Aggregates_VideoAggregateRoot_LiveAggregation(Marten.Events.Aggregation.AggregateProjection<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot> aggregateProjection)
    {
        _aggregateProjection = aggregateProjection;
    }


    public System.Action<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot, Iot.Replayer.Domain.Events.VideoViewedEvent> Lambda1 {get; set;}

    public System.Action<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot, Iot.Replayer.Domain.Events.VideoInitializedEvent> Lambda2 {get; set;}


    public override Iot.Replayer.Domain.Aggregates.VideoAggregateRoot Build(System.Collections.Generic.IReadOnlyList<Marten.Events.IEvent> events, Marten.IQuerySession session, Iot.Replayer.Domain.Aggregates.VideoAggregateRoot snapshot)
    {
        if (!events.Any()) return null;
        Iot.Replayer.Domain.Aggregates.VideoAggregateRoot videoAggregateRoot = null;
        snapshot ??= Create(events[0], session);
        foreach (var @event in events)
        {
            snapshot = Apply(@event, snapshot, session);
        }

        return snapshot;
    }


    public Iot.Replayer.Domain.Aggregates.VideoAggregateRoot Create(Marten.Events.IEvent @event, Marten.IQuerySession session)
    {
        throw new System.InvalidOperationException("There is no default constructor for Iot.Replayer.Domain.Aggregates.VideoAggregateRoot");
    }


    public Iot.Replayer.Domain.Aggregates.VideoAggregateRoot Apply(Marten.Events.IEvent @event, Iot.Replayer.Domain.Aggregates.VideoAggregateRoot aggregate, Marten.IQuerySession session)
    {
        switch (@event)
        {
            case Marten.Events.IEvent<Iot.Replayer.Domain.Events.VideoViewedEvent> event_VideoViewedEvent1:
                Lambda1.Invoke(aggregate, event_VideoViewedEvent1.Data);
                break;
            case Marten.Events.IEvent<Iot.Replayer.Domain.Events.VideoInitializedEvent> event_VideoInitializedEvent2:
                Lambda2.Invoke(aggregate, event_VideoInitializedEvent2.Data);
                break;
        }

        return aggregate;
    }

}

// END: AggregateProjection_Iot_Replayer_Domain_Aggregates_VideoAggregateRoot_LiveAggregation


// START: AggregateProjection_Iot_Replayer_Domain_Aggregates_VideoAggregateRoot_InlineHandler
public class AggregateProjection_Iot_Replayer_Domain_Aggregates_VideoAggregateRoot_InlineHandler : Marten.Events.Aggregation.AggregationRuntime<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot, string>
{
    private readonly Marten.IDocumentStore _store;
    private readonly Marten.Events.Aggregation.IAggregateProjection _projection;
    private readonly Marten.Events.Aggregation.IEventSlicer<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot, string> _slicer;
    private readonly Marten.Storage.ITenancy _tenancy;
    private readonly Marten.Internal.Storage.IDocumentStorage<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot, string> _storage;
    private readonly Marten.Events.Aggregation.AggregateProjection<Iot.Replayer.Domain.Aggregates.VideoAggregateRoot> _aggregateProjection;

    public AggregateProjection_Iot_Replayer_Domain_Aggregates_VideoAggregateRoot_InlineHandler(Marten.IDocumentStore store, Marten.Events.Aggregation.IAggregateProjection projection, Marten.Eve
my AggregateRoot:
` public class VideoAggregateRoot : AggregateRoot
{
public string Id
{
get
{
return string.IsNullOrEmpty(VideoId) ? string.Empty : $"Provider-{Provider}|VideoId-{VideoId}";
}
private set
{
}
}
    public ProviderEnum Provider { get; private set; }
    public string VideoId { get; private set; }
    public ICollection<ViewValueObject> Views { get; private set; }

    public VideoAggregateRoot(ProviderEnum provider, string videoId)
    {
        if (string.IsNullOrEmpty(videoId))
            throw new ArgumentNullException(nameof(videoId));
        Provider = provider;
        VideoId = videoId;
    }

    public VideoAggregateRoot Initialize()
    {
        var @event = new VideoInitializedEvent(Provider, VideoId);
        AddDomainEvent(@event);
        Apply(@event);
        return this;
    }

    public VideoAggregateRoot View(Int64 startTime, Int64 endTime, string ipAddress, Guid? viewerId)
    {
        var @event = new VideoViewedEvent(Provider, VideoId, startTime, endTime, ipAddress, DateTime.UtcNow, viewerId);
        AddDomainEvent(@event);
        Apply(@event);
        return this;
    }

    private void Apply(VideoViewedEvent @event)
    {
        Provider = @event.Provider;
        VideoId = @event.VideoId;
        var view = new ViewValueObject(@event.StartTime, @event.EndTime, @event.IpAddress, @event.ViewedTime, @event.ViewerId);
        Views.Add(view);
    }

    private void Apply(VideoInitializedEvent @event)
    {
        Provider = @event.Provider;
        VideoId = @event.VideoId;
        Views = new Collection<ViewValueObject>();
    }
}`
public class ViewValueObject { public Int64 StartTime { get; private set; } public Int64 EndTime { get; private set; } public string IpAddress { get; private set; } public Guid? ViewerId { get; private set; } public DateTime ViewedTime { get; private set; } public ViewValueObject(Int64 startTime, Int64 endTime, string ipAddress, DateTime viewedTime, Guid? viewerId) { ViewedTime = DateTime.UtcNow; StartTime = startTime; EndTime = endTime; IpAddress = ipAddress; ViewerId = viewerId; ViewedTime = viewedTime; } }
please help me. thanks you so much
i receive error when i execute Initialize()
Oskar Dudycz
@oskardudycz
My rough guess is that it might be an issue with Id with calculated setter or lack of default constructor
Jeremy D. Miller
@jeremydmiller
@MinhMit The easiest way to troubleshoot codegen problems is to jsut copy/paste the generated code into a code file and let VS/ReSharper tell you where the syntax issues are.
Then let me know what it says. Nothing jumps out at me offhand.
JT
@Hawxy
Could you try updating to Alpha 10? The error is very similar to the issue I encountered.
Oskar Dudycz
@oskardudycz
Folks, I recently updated my Event Sourcing sample repository, there is more written explanation of the fundamental concepts https://github.com/oskardudycz/EventSourcing.NetCore#1-event-sourcing.
mkooiman
@mkooiman

Hi again, we seem to have an issue on one of our databases where connections seem to get stuck executing the following query:

SELECT format('DROP FUNCTION IF EXISTS %s.%s(%s);'
             ,n.nspname
             ,p.proname
             ,pg_get_function_identity_arguments(p.oid))
FROM   pg_proc p
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE  p.proname = $1
AND    n.nspname = $2

Has anyone ever encountered this behaviour?
I'm on the latest 3.13 release

Jeremy D. Miller
@jeremydmiller
Is this in production? If it is, go to AutoCreate.None so Marten doesn’t even issue that query
mkooiman
@mkooiman
okay, will do
Jeremy D. Miller
@jeremydmiller
And if that’s really happening often, I’d also double check that you’re not re-creating the DocumentStore
mkooiman
@mkooiman
it's on our testing machine, problem is that it's not allowed to make many connections
Jeremy D. Miller
@jeremydmiller
Ah, gotcha. You still might be able to slide around the issue by forcing Marten to apply all updates upfront, because that would only use one connection
mkooiman
@mkooiman
That seems to have fixed it, thanks for the help!
Trong Phan
@vantrong1985

Hi, can someone explain me what is different with codes following:

await session.SaveChangesAsync();

and

try {
       await session.SaveChangesAsync();
}
catch {
       log something;
}

Do we need try/catch block to wrap await session.SaveChangesAsync();

davevw-keri
@davevw-keri

In a multi-tenancy production server using Marten, is it acceptable to use raw SQL to optionally create a unique index, say like on a PIN field [some tenants will have unique, some not] that is already mapped between Marten and Postgresql?

Will adding/dropping a unique index on the fly (as I've already done in dev) break or complicate the marten schema patch process in production? Or am I overlooking another best-practice?

Oskar Dudycz
@oskardudycz
That shouldn’t be an issue unless you don't use the auto schema changes apply
Or in fact, you can still use it with CreateOrUpdate
davevw-keri
@davevw-keri
Mostly I want to avoid any risk of having this index (as it is optional) ever show up in any schema patches unbeknownst to the next developer (or self). So restrictions or relaxations to the PIN field are not applied/dropped to other tenants when it should not be.
Oskar Dudycz
@oskardudycz
@vantrong1985 that depends if you want to have in-place error handling
@davevw-keri, what’s your current schema generation strategy?
I’d suggest to use the schema generation as it is, then apply additional indexes after the Marten schema changes were applied
Plus, do the schema generation in advance. Not using the auto schema generation on prod.
Then imho, you should be safe
Jeremy D. Miller
@jeremydmiller
I think in v3.* that Marten will ignore extra indexes it doesn’t know about. I’m actually in the middle of reworking that code for v4 and that would no longer be true. I’m gonna have to think about that a little more
But the v4 model would be much more flexible in terms of what indexes you can do, including the ability to do WHERE in the index
davevw-keri
@davevw-keri

@oskardudycz We have to manually manage capture and add database patches to a list in development. I guess I need to review how the patches are really created and whether a custom index applied later will ever break the process.

@jeremydmiller Thanks for the response, using v3.10 now. Just(ha!) looking for what a best practice should be... whether an optional SQL index is allowed, or need to guarantee uniqueness another way.

(optional uniqueness)
Oskar Dudycz
@oskardudycz
It should not break any Marten internals
Ah, I just noticed Jeremy’s answer. I wasn't aware of the upcoming v4 changes. For 3.x, it should be fine.
davevw-keri
@davevw-keri
Sounds like I may get away with it in v3.10, but will have to address differently or more carefully with v4. Thanks .
Jeremy D. Miller
@jeremydmiller
@oskardudycz As part of #1467. Pulling all the ISchemaObject type stuff out and treating it like a standalone lib.