Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 12 15:13
    RyanThomas73 opened #264
  • Oct 02 16:48

    jeremydmiller on master

    Added Setter.StaticReadOnly opt… (compare)

  • Sep 29 15:11
    DrMueller commented #199
  • Sep 29 12:18
    jeremydmiller commented #199
  • Sep 29 11:18
    DrMueller commented #199
  • Sep 24 04:56
    athamala opened #263
  • Sep 23 08:21
    paziz001 commented #252
  • Sep 23 08:20
    paziz001 commented #252
  • Sep 23 08:18
    paziz001 opened #262
  • Sep 23 07:10
    paziz001 commented #252
  • Sep 18 05:28
    valdisiljuconoks opened #261
  • Sep 03 22:45
    hahn-kev opened #260
  • Aug 12 05:27
    NimaFx commented #256
  • Aug 12 05:22
    NimaFx synchronize #256
  • Jul 31 07:41
    danijel88 closed #259
  • Jul 27 19:17
    jeremydmiller commented #250
  • Jul 27 19:13
    mxmissile commented #250
  • Jul 24 12:35
    danijel88 opened #259
  • Jul 22 06:16
    OmerNassie commented #254
  • Jul 20 22:03
    jeremydmiller closed #257
Bryan Boettcher
@bryanboettcher
to facilitate this, NPoco also has a "DatabaseFactory" object that has its own GetDatabase() method -- but there are a variety of expensive builders to construct the factory itself
Jeremy D. Miller
@jeremydmiller
“as far as i can tell, each round-trip to the database should get a new one” — that sounds slow
Bryan Boettcher
@bryanboettcher
well, i tried reusing them, and started getting intermittent connection-closed errors
they're using SqlConnection under the hood, which is using connection pooling
Jeremy D. Miller
@jeremydmiller
Typically you’d have any kind of “unit of work” service Scoped in the container so it’s shared within a logical transaction / http request / message handling session
Bryan Boettcher
@bryanboettcher
in the case of making 7 disparate requests to the database (THAT is what it is, that's changing from a different direction) to return one object, are you suggesting a scope-per-domain-object?
Jeremy D. Miller
@jeremydmiller
And I’m assuming that the DatabaseFactory is expensive to build up? So you have that as a singleton in the system?
No. I’m suggesting a scope per logical action. So if you’re using a bunch of different repository objects to build up one object (why do you need to do that btw?), make sure those little repositories share the same NPoco Database would be my call.
Bryan Boettcher
@bryanboettcher
my assumption is the Factory is expensive, because i have to make a call to "context.GetAllInstances<IPocoMapper>" as part of the building
Haiping
@Oceania2018
Hi @jeremydmiller I came across found there is Building Objects with Lambdas in Lamar, I'm wondering if I can use it to do another challenge task: vescon/MethodBoundaryAspect.Fody#79. I've trying to use MethodBoundaryAspect but it doesn't meet all my requirements. BTW, I'm the contributor for open source project TensorFlow.NET. I'm looking forward to hear from you. Another related issue (resolved) is: vescon/MethodBoundaryAspect.Fody#77.
Jeremy D. Miller
@jeremydmiller
Isn’t Fody for compile time AOP, or am I misremembering that?
@bryanboettcher Are you doing service location inside of the DatabaseFactory? Do you have to do it that way? If it’s a singleton, there’d be a perf advantage to strictly using DI ( and there usually is anyway ).
Bryan Boettcher
@bryanboettcher
i think my problem can go away if i can get both ThreadLocal + scoped for the database objects -- is there a pattern for that?
Jeremy D. Miller
@jeremydmiller
Not in Lamar itself, but you can do that yourself with a lambda construction in Lamar
Haiping
@Oceania2018
I think it's yes. It uses IL weaving.
Jeremy D. Miller
@jeremydmiller
So that doesn’t impact Lamar in that case if it’s compile time, or am I missing something?
Bryan Boettcher
@bryanboettcher
@jeremydmiller would i set the lifespan on the instance to transient so it executes my ThreadLocal<T>.Value every time?
Jeremy D. Miller
@jeremydmiller
That’s probably going to be problematic. Why do you want to use ThreadLocal?
Haiping
@Oceania2018
I'm stuck at how to translate a < b ? a : b to tf.cond(a < b, () => a, () => b) automatically. @jeremydmiller Do you have any idea about this?
Bryan Boettcher
@bryanboettcher
@jeremydmiller because the Database object isn't thread safe, but performance suffers pretty hard if i try and get new ones constantly
Jeremy D. Miller
@jeremydmiller
@Oceania2018 Sorry, no, I don’t. Besides Fody though, you could also look at LamarCodeGeneration as a way to work w/ generated C# instead of IL
@bryanboettcher So why not always be pulling it from a scoped/nested container instead of trying to do your own lifecycle on top of / separate from the container?
Haiping
@Oceania2018
LamarCodeGeneration should be helpful. Is it possible to get the syntax tree for a < b ? a : b ? and replace it in LamarCodeGeneration ?
Jeremy D. Miller
@jeremydmiller
That’s not what it does, no, sorry. I don’t have anythign for you if you’re just looking to rewrite IL
Bryan Boettcher
@bryanboettcher
the 7 operations to build the tables are done asynchronously and i haven't found the right combination of .Scoped & .Transient to make it give me new instances only when needed
if the same database object is reused across all 7 operations at once then it dies with threading problems
Jeremy D. Miller
@jeremydmiller
Pull the whole aggregate service down from a scoped container? Or do you have service location usages in there too?
Haiping
@Oceania2018
Or generate a new function, call the new function though AOP. the most important thing is we need to get the whole function syntax tree, correct me if I'm wrong.
Jeremy D. Miller
@jeremydmiller
I don’t have enough context to help you here tbh
Haiping
@Oceania2018
image.png
The goal is simple, need a kind of tool to replace some specific statement with another statement at compile time. this feature is used in Tensorflow AutoGraph.
Jeremy D. Miller
@jeremydmiller
The Fody team is gonna be a better resource here than me.
Haiping
@Oceania2018

The Fody team is gonna be a better resource here than me.

OK, still thank you.

Mark Warpool
@CodingGorilla
@jeremydmiller Have you looked at 'Source Generators' yet?
Jeremy D. Miller
@jeremydmiller
A little bit, yes. Not usable for Lamar or Jasper for that matter if that’s what you’re asking
Mark Warpool
@CodingGorilla
It was... I haven't looked into them much, why do you say they're not usable?
Jeremy D. Miller
@jeremydmiller
You can’t easily do any runtime discovery or Reflection of the running assembly or its dependencies. Still can’t do anything to access or call internal members
hariharankv11
@hariharankv11
Hi Team, trying to get some help here on Lamar DI implementation , with Microsoft DI we have below implementation on an extension method of IServiceCollection services.AddSingleton<IInterface, ClassA>(ctx => //where ctx is IServiceProvider
{
return new ClassA(options);
}); Trying to implement the same with Registry approach in Lamar, please advise ? seems am not able to get "ctx" when using registry to access services from IServiceProvider
Jeremy D. Miller
@jeremydmiller
You should be able to use the exact same syntax. The AddSingleton method is an extension method, so if you’re doing it within a ServiceRegistry, you’d have to use the this keyword. Or the idiomatic Lamar usage would be:
ForSingletonOf<T>().Use(ctx => build your thing);
hariharankv11
@hariharankv11
Thanks @jeremydmiller , so we can use the same mappings we have for microsoft DI registrations, I don't need to re-write them to any Lamar specific methods correct ? I was trying to find equivalents in Lamar to migrate to
Jeremy D. Miller
@jeremydmiller
Lamar can use either the MS DI abstractions or the StructureMap compliant DSL shown here (https://jasperfx.github.io/lamar/documentation/ioc/registration/registry-dsl/). And that can be mixed and matched at will. There’s more functionality in the idiomatic Lamar API though.
hariharankv11
@hariharankv11
:) thank you !
Bryan Harris
@gufi
i'm trying to do something similar to the above. however it throws an exception about <IMyType> cannot be converted to Lamar.IoC.Instances.ObjectInstance
if i use a lambda it throws saying pretty much same thing but that it's a lambda instance and cant convert to <IMyType>
.UseInstance doesnt exist as far as i can tell but is listed in the documentation
Jeremy D. Miller
@jeremydmiller
There’s still a little bit of old StructureMap sample code leaking into the documentation. What exactly are you trying to do in your registration?
Bryan Harris
@gufi
well... honestly i figured out what my problem was
i had the .UseLamar within the ConfigureWebHostDefaults lambda instead of hanging off the CreateDefaultBuilder call
understanding how that builder works makes all the sense to me but man, that was annoying to debug -_- lol