Equivalent in Autofac of TryAddEnumerable from default .net DI - autofac

I am having a hard time finding the answer to my question so I am gonna put it like that.
This in .net 7 :
services.TryAddEnumerable(ServiceDescriptor.Scoped\<CircuitHandler, MyCustomCircuit\>());
does the equivalent in Autofac is :
builder.RegisterType\<MyCustomCircuit\>().As\<CircuitHandler\>().InstancePerMatchingLifetimeScope();

Related

Is there any way to make F# discriminated unions work in Unity?

I am experimenting with F# in Unity. I use compiled F# library and FSharp.Core.dll copied to Assets in Unity. Simple scripts work but when I add discriminated union type like
type A =
| AInt of int
| AString of string
then I get this error in Unity: "Unable to load attribute info on method fs.A:.ctor (). Are you missing a reference?".
What can be wrong and is there a way to make it work?
Ensure you are using F# 4.1 - 4.8 in order to be compatible with Unity. F# 5 and 6 are incompatible in exactly the same way as a C# project targeting beyond .NET Standard 2.1.
Tell me more
.NET profile support
https://en.wikipedia.org/wiki/F_Sharp_(programming_language)
.NET Standard Versions

BeginTransaction with IsolationLevel in EF Core

I'm trying to rewrite old library to use EntityFramework Core and I can't figure out how to begin transaction with specific isolation level.
Previously I was able to do something like this:
DbContext.Database.BeginTransaction(IsolationLevel.Snapshot);
What is alternative implementation in the EntityFramework Core?
The EF Core code is exactly the same.
DbContext.Database.BeginTransaction(IsolationLevel.Snapshot);
The only difference is that in EF Core the method with isolation level (as many others) is an extension method, defined in RelationalDatabaseFacadeExtensions class, and importantly, located in Microsoft.EntityFrameworkCore.Relational assembly.
So if you have using Microsoft.EntityFrameworkCore; and don't see it, add reference to the Microsoft.EntityFrameworkCore.Relational.dll assembly / package.
In addition to Ivan Stoev's answer, it is also important to use System.Data.IsolationLevel and not System.Transactions.IsolationLevel when calling BeginTransaction method.

AjaxControlToolKit 3.02 to 16.1 Migration - ScriptObjectBuilder not available

We are migrating AjaxControlToolKit 3.02 to 16.1 used in a ASP.NET project.We have following code snippet in the existing 3.02 version:
AjaxControlToolkit.ScriptObjectBuilder.GetScriptReferences()
While AjaxControlToolKit version is updated to 16.1 the above code snippet is not complied due to unavailability of the ScriptObjectBuilder class and GetScriptReferences method. It seems the class is deprecated in the higer version of the library.
In that case, how the above code can be re-written to achieve the same functionality?
Any approach or suggestion would help us.
It seems that there is no direct analogue to this method.
The ToolkitResourceManager class is a successor of the ScriptObjectBuilder and has many methods for registering resources.
Foe example, it has GetControlScriptReferences(Type type) method. It calls GetEmbeddedScripts(params string[] toolkitBundles) internally, which is private now.

Drools .NET 3.0 - List<> C#

I am using Drools. Net 3.0, but I can not use list structures as exists in Drools java version.
example:
//Code Drools - This code does not work in Drools. NET
rule 'ListC#'
when
Object1 ($list: listObjects)
Object2 (date> = '01/01/1992') from $list
then
mensagens.add ("132");
end
//C# Code
class Object1
{
public List < Object2> listObjects {get; sets;}
}
Does anyone have any idea how I can fix?
Drools in java is already in version 6, so the .NET port is really outdated by now. I wouldn't expect the new rule syntax to work with the old .NET port.. you can try to find out the drools 3.0 docs out there.. but there is no guarantee that it will work.

InsertHistoryOperation throws InvalidOperationException while no Database is existing

i have big Trouble using the EntityFramework 5.0. After updating EF in our Project from EF4.2 to EF5.0. The Framework throws InvalidOperationExceptions in the TypeInitializer of InsertHistoryOperation during initializing of the database. (In the InnerException it says: "The List does not contain any element").
I tried using DropCreateAlwaysInitializer as well as DropWhenModelChanges. We don't need the Migration Feature (Sure, would be nice to have, but not recommend). Is there a way to disable the Migration Feature so the exception is not thrown. Or can somebody give me a hint what i did wrong?
The Model is very complex, so i think its not very useful to post it here.
best regards,
Chris
I tried with .Net4.0 and .Net4.5
Ok, i got it.
The Problem is that the EntityFramework since V5.0 is not able to work correctly if you merge it into (e.g. a Datalayer Assembly) or use it from a merged assembly. (ILMerge).