Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "DennisAhlin"

I get null reference exception when trying to include children in tests and I cannot figure out why? Error:

System.NullReferenceException : Object reference not set to an instance of an object.
   at lambda_method(Closure , AnonymousObject )
   at System.Linq.Lookup`2.CreateForJoin(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.<JoinIterator>d__37`4.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryBuffer.IncludeCollection(Int32 includeId, INavigation navigation, INavigation inverseNavigation, IEntityType targetEntityType, IClrCollectionAccessor clrCollectionAccessor, IClrPropertySetter inverseClrPropertySetter, Boolean tracking, Object entity, Func`1 relatedEntitiesFactory)
   at lambda_method(Closure , QueryContext , Parent , Object[] )
   at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler._Include[TEntity](QueryContext queryContext, TEntity entity, Object[] included, Action`3 fixup)
   at lambda_method(Closure , Parent )
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at lambda_method(Closure , QueryContext )
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass17_0`1.&lt;CompileQueryCore&gt;b__0(QueryContext qc)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
   at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)......

If I remove IMustHaveTenant from Child, the code works? My classes:

public class Parent : FullAuditedEntity
{
    public virtual ICollection&lt;Child&gt; Children { get; set; }
}

public class Child : FullAuditedEntity, IMustHaveTenant
{
    [Required]
    public int TenantId { get; set; }

    [ForeignKey("ParentId")]
    public virtual Parent Parent { get; set; }
    [Required]
    public virtual int ParentId { get; set; }
}

The test (that throws the exception):

var parentId = 1;
var tenantId = GetCurrentTenant().Id;

//Arrange
UsingDbContext(ctx =>
{
    ctx.Parents.Add(new Parent
    {
        Id = parentId
    });
                
    ctx.Children.Add(new Child
    {
        TenantId = tenantId,
        ParentId = parentId
    });
});

//Act
//I want to test stuff here that should change parent and/or children
            
//Assert
var parent = UsingDbContext(ctx =>
{
    return ctx.Parents.Include(p => p.Children).Single(i => i.Id == parentId); //Exception thrown here
});

parent.Id.ShouldBe(1);

parent.Children.Count.ShouldBe(1);
parent.Children.First().ParentId.ShouldBe(parentId);
parent.Children.First().TenantId.ShouldBe(tenantId);

Hi! I have an integration entity, which have many integration step entities. The steps also have links to other steps in the same integration.

Like

Integration1 || \ Step1 = Step2

I can not figure out how to get the cascade deletion working when I delete an integration? The integration is deleted, but not the integration steps. How can I solve this?

Hi! TL;DR: .NET Clients generated from swagger.json cannot parse models from API because they think that response.Content will contain the Model, but the model is wrapped in a response class, which makes the deserialization fail. How to solve this?

I am making a .NET client for accessing my application's API externally, so I've generated a client with Swagger Codegen (<a class="postlink" href="https://github.com/swagger-api/swagger-codegen">https://github.com/swagger-api/swagger-codegen</a>). But when the client is trying to parse a response, it fails because it thinks that the request.Content is going to be the same as the model defined in the swagger.json, but it isn't. The model is wrapped in a response body, which makes the deserialization fail.

I.e. for TokenAuth/Authenticate client expects response.Content be like { "accessToken": "wtqt2...warar", "encrypted..": ...}, but instead it is {"result": { "accessToken": "wtqt2...warar", "encrypted..": ...}, "targetUrl": "..", ....}.

I'm not sure where the fault lies here, is there something wrong in the swagger.json, Swagger Codegen or is there some kind of configuration in Codegen I'm missing?

PS. I did a quick try in NSwag and the problem seems to be there as well. Weird thing is that it obviously works for DS.

Regards

Hi!

My classes:

public class Member: FullAuditedEntity, IMustHaveTenant
    {
        [Required]
        public int TenantId { get; set; }

        [ForeignKey("CompanyId")]
        public virtual Company Company { get; set; }
        public virtual int? CompanyId { get; set; }
    }
public class Company : FullAuditedEntity
    {
        [Required]
        public string Title { get; set; }
        public virtual ICollection<Member> Members { get; set; }
    }

I want the list of all members after adding a member to a company, like this:

...
newMember.CompanyId = 12;
await _repository.InsertAsync(newMember);
await CurrentUnitOfWork.SaveChangesAsync();
var membersOfCompany = newMember.Company?.Members;
...

But the newMember.Company is null after the save changes? How can I load the cooperation entity to the new member?

Hi! I need to store some login credentials (username/password) to external services (like FTP accounts) that my users can enter. Therefore I need to store these in the database, but of course not in plain text, so I need to encrypt it in some way so that I can decrypt them later and use them to access the FTP account from my server. Is there a utility for this in ABP or Zero? I figured user passwords are hashed by Identity.IPasswordHasher, but as far as I can tell, those passwords are not retrievable (as they should), so that's not an option.

Regards.

When Swedish language is selected (sv-SE or sv), LocalizedResourcesHelper tries to find jquery.jtable.sv-SE.js or jquery.jtable.sv.js here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/3c65f620aab8042b9b85109054c606836d15b8ed/angular/src/shared/helpers/LocalizedResourcesHelper.ts#L40">https://github.com/aspnetzero/aspnet-ze ... per.ts#L40</a> Too bad the language file is called jquery.jtable.se.js, so we get a 404. The same goes for jquery timeago.

Bootstrap Select also checks for supported cultures, so it reverts to english, since it cannot find sv-SE or sv in the supportedCultures array.

This is probably not only a problem with Swedish. How to solve this best?

Hi! When using domain resolved tenants, the website root address setting have incosistent behaviour.

If I have: server at: <a class="postlink" href="http://tenant.api.mydomain.com">http://tenant.api.mydomain.com</a> angular ui at: <a class="postlink" href="http://tenant.mydomain.com">http://tenant.mydomain.com</a>

When server is trying to figure out which tenant is enabled, it uses the host address (<a class="postlink" href="http://tenant.api.mydomain.com">http://tenant.api.mydomain.com</a>) here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/850fbe6d851ccdb906c05f77d88b4003de6e1d5c/src/Abp.AspNetCore/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs#L41">https://github.com/aspnetboilerplate/as ... tor.cs#L41</a> and compares it to the _multiTenancyConfiguration.DomainFormat, which is App:WebSiteRootAddress setting, so App:WebSiteRootAddress needs to be set to the format of the host (http://{TENANCY_NAME}.api.mydomain.com).

However, when an activation mail is sent when creating a tenant here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/1ead91936c496521e171f3fdf70d129bee021ff2/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Core/Url/AppUrlServiceBase.cs#L34">https://github.com/aspnetzero/aspnet-ze ... ase.cs#L34</a> , the activation link uses WebUrlService.GetSiteRootAddress, which is also the App:WebSiteRootAddress setting. This leads to the activation link becomes <a class="postlink" href="http://tenant.api.mydomain.com/route">http://tenant.api.mydomain.com/route</a>, which is wrong. It should be <a class="postlink" href="http://tenant.mydomain.com/route">http://tenant.mydomain.com/route</a>, otherwise the link doesn't work.

Maybe separate WebSiteRootAddress into two settings? And also name them more clearly (ClientRootAddressFormat/HostRootAddressFormat)?

As a side note, when having the setting without the trailing slash as workaround for previous tenant domain resolver bug, the activation link misses slash between root and relative path (<a class="postlink" href="http://tenant.api.mydomain.comroute">http://tenant.api.mydomain.comroute</a>). I think the url in AppUrlService base should be concatenated in some way that is not sensitive to having a trailing slash or not.

Hi! For some reason, register tenant doesn't work in my .NET Core solution. Not from Swagger nor angular ui. It does not reach my breakpoint on first line of TenantRegistrationAppService/RegisterTenant method but returns 500 response code. Other endpoints, like Account/Register works as expected.

Here is my swagger post: <a class="postlink" href="https://www.dropbox.com/s/brh6bqpuppo6mde/Sk%C3%A4rmklipp%202017-03-21%2012.30.51.png">https://www.dropbox.com/s/brh6bqpuppo6m ... .30.51.png</a>

Hi! I've been trying to get this to work for a few days now. How am I supposed to configure host and client to be able to use multi tenancy, both in localhost, staging and production servers? Solution is .NET Core + Angular 2. In all environments, when I go localhost:4200/staging.mydomain.com/mydomain.com or default.localhost:4200/default.staging.mydomain.com/default.mydomain.com i get the centered loading spinner and after a while a modal with "An error occured/Error detail not sent by server.". I can't see any failed requests in the Network view in Chrome Developer Tools.

Localhost: Currenty I have configured angular appconfig.json like this:

{
  "remoteServiceBaseUrl": "http://localhost:22742",
  "appBaseUrl": "http://{TENANCY_NAME}.localhost:4200"
}

and .Net appsettings.json like this:

"App": {
    "WebSiteRootAddress": "http://localhost:22742"
  }

Staging: Angular appconfig.json:

{
  "remoteServiceBaseUrl": "http://{TENANCY_NAME}.api.staging.mydomain.com",
  "appBaseUrl": "http://{TENANCY_NAME}.staging.mydomain.com"
}

.Net appsettings.json:

"App": {
    "WebSiteRootAddress": "http://{TENANCY_NAME}.staging.mydomain.com/"
  }

Production: Angular appconfig.json:

{
  "remoteServiceBaseUrl": "http://{TENANCY_NAME}.api.mydomain.com",
  "appBaseUrl": "http://{TENANCY_NAME}.mydomain.com"
}

.Net appsettings.json:

"App": {
    "WebSiteRootAddress": "http://{TENANCY_NAME}.mydomain.com/"
  }

Please help, what am I doing wrong? :geek:

Showing 1 to 9 of 9 entries