I tried... same error
By the way is it correct to use 4.6.1 as target framework or I should stay on 4.5.1?
Could it be some wrong dll version?
here my configs
CORE
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.9.5.0" targetFramework="net461" />
<package id="Abp.AutoMapper" version="0.9.5.0" targetFramework="net461" />
<package id="Abp.Zero" version="0.9.4.0" targetFramework="net461" />
<package id="Abp.Zero.Ldap" version="0.9.4.0" targetFramework="net461" />
<package id="AutoMapper" version="4.2.1" targetFramework="net461" />
<package id="Castle.Core" version="3.3.3" targetFramework="net451" />
<package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
<package id="Nito.AsyncEx" version="3.0.1" targetFramework="net451" />
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net461" />
</packages>
EntityFramework
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.9.5.0" targetFramework="net461" />
<package id="Abp.AutoMapper" version="0.9.5.0" targetFramework="net461" />
<package id="Abp.EntityFramework" version="0.9.5.0" targetFramework="net461" />
<package id="Abp.EntityFramework.Common" version="0.9.5.0" targetFramework="net461" />
<package id="Abp.Zero" version="0.9.4.0" targetFramework="net461" />
<package id="Abp.Zero.EntityFramework" version="0.9.4.0" targetFramework="net461" />
<package id="AutoMapper" version="4.2.1" targetFramework="net461" />
<package id="Castle.Core" version="3.3.3" targetFramework="net461" />
<package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
<package id="EntityFramework" version="6.1.3" targetFramework="net451" />
<package id="EntityFramework.DynamicFilters" version="1.4.10.2" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
<package id="Nito.AsyncEx" version="3.0.1" targetFramework="net451" />
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net461" />
</packages>
application
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.9.5.0" targetFramework="net461" />
<package id="Abp.AutoMapper" version="0.9.5.0" targetFramework="net461" />
<package id="Abp.Zero" version="0.9.4.0" targetFramework="net461" />
<package id="Abp.Zero.Ldap" version="0.9.4.0" targetFramework="net461" />
<package id="AutoMapper" version="4.2.1" targetFramework="net461" />
<package id="Castle.Core" version="3.3.3" targetFramework="net451" />
<package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
<package id="EntityFramework" version="6.1.3" targetFramework="net451" />
<package id="EPPlus" version="4.0.5" targetFramework="net452" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
<package id="Nito.AsyncEx" version="3.0.1" targetFramework="net451" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net461" />
<package id="System.Collections.Immutable" version="1.1.36" targetFramework="net461" />
<package id="System.Linq.Dynamic" version="1.0.6" targetFramework="net452" />
</packages>
Thanks in advance for your support. Here are my entities:
Partner:
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using Abp.Domain.Entities.Auditing;
using System.Collections.Generic;
namespace stake.Partners
{
[Table("stakePartners")]
public class Partner : FullAuditedEntity
{
public const int MaxNameLength = 50;
public const int MaxSurnameLength = 50;
[Required]
[MaxLength(MaxNameLength)]
public virtual string Name { get; set; }
[Required]
[MaxLength(MaxSurnameLength)]
public virtual string Surname { get; set; }
public virtual RelationshipType RelationshipType { get; set; }
public virtual ResponseLevel ResponseLevel { get; set; }
public virtual InterestLevel InterestLevel { get; set; }
public virtual InfluenceLevel InfluenceLevel { get; set; }
public virtual InfluenceArea InfluenceArea { get; set; }
public virtual InterestArea InterestArea { get; set; }
public virtual ReactivityLevel ReactivityLevel { get; set; }
public virtual LikingLevel LikingLevel { get; set; }
public virtual ICollection<Phone> Phones { get; set; }
public virtual ICollection<Social> Socials { get; set; }
public virtual ICollection<Email> Emails { get; set; }
public virtual ICollection<Address> Addresses { get; set; }
}
}
Phone:
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using Abp.Domain.Entities.Auditing;
using System.Collections.Generic;
namespace stake.Partners
{
[Table("stakePhones")]
public class Phone : FullAuditedEntity
{
public const int MaxNumberLength = 16;
[ForeignKey("PartnerId")]
public virtual Partner Partner { get; set; }
public virtual int PartnerId { get; set; }
[ForeignKey("PhoneTypeId")]
public virtual PhoneType PhoneType { get; set; }
public virtual int PhoneTypeId { get; set; }
[Required]
[MaxLength(MaxNumberLength)]
public virtual string Name { get; set; }
}
}
Phonetype (to complete the chain:
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using Abp.Domain.Entities.Auditing;
using System.Collections.Generic;
namespace stake.Partners
{
[Table("stakePhoneTypes")]
public class PhoneType : FullAuditedEntity
{
public const int MaxNameLength = 50;
[Required]
[MaxLength(MaxNameLength)]
public virtual string Name { get; set; }
public virtual ICollection<Phone> Phones { get; set; }
}
}
I found this, very similar to what I try to do in a classic book on Entity Framework programming, but we do not have anyway to use it in ABP, for what I know
private static void SaveDestinationAndLodgings(
Destination destination,
List<Lodging> deletedLodgings)
{
// TODO: Ensure only Destinations & Lodgings are passed in
using (var context = new BreakAwayContext())
{
context.Destinations.Add(destination);
if (destination.DestinationId > 0)
{
context.Entry(destination).State = EntityState.Modified;
}
foreach (var lodging in destination.Lodgings)
{
if (lodging.LodgingId > 0)
{
context.Entry(lodging).State = EntityState.Modified;
}
}
foreach (var lodging in deletedLodgings)
{
context.Entry(lodging).State = EntityState.Deleted;
}
context.SaveChanges();
}
}
Yes it is in application service and here it is last version
[AbpAuthorize(AppPermissions.Pages_Tenant_Partners_CreatePartner)]
public async Task EditPartner(EditPartnerInput input)
{
var partner = input.MapTo<Partner>();
var phones = input.Phones.MapTo<List<Phone>>();
var phonesToDelete = input.DeletedPhones.MapTo<List<Phone>>();
var query = await _partnerRepository.UpdateAsync(partner);
foreach (var phone in phones)
{
if (phone.Id == 0)
{
{
// var currentPartner = _partnerRepository.Get(partner.Id);
// currentPartner.Phones.Add(phone);
//// await CurrentUnitOfWork.SaveChangesAsync();
await _phoneRepository.InsertAsync(phone);
await CurrentUnitOfWork.SaveChangesAsync();
}
}
else
{
var phoneToUpdate = await _phoneRepository.GetAsync(phone.Id);
phone.MapTo(phoneToUpdate);
await _phoneRepository.UpdateAsync(phoneToUpdate);
}
}
foreach (var phoneToDelete in phonesToDelete)
{
await _phoneRepository.DeleteAsync(phoneToDelete.Id);
}
}
No way.... same error.
Should I change my Dto?
I tried both, the commented and uncommented:
using Abp.AutoMapper;
using Abp.Application.Services.Dto;
using System.Collections.ObjectModel;
namespace stake.Partners.Dto
{
[AutoMapTo(typeof(Partner))]
public class EditPartnerInput : IInputDto
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
//public Collection<PhoneInEditPartnerDto> Phones { get; set; }
public PartnerPhoneDto[] Phones { get; set; }
public PartnerPhoneDto[] DeletedPhones { get; set; }
}
//[AutoMapTo(typeof(Phone))]
//public class PhoneInEditPartnerDto : EntityDto
//{
// public string Name { get; set; }
// public int PartnerId { get; set; }
// public int PhoneTypeId { get; set; }
//}
}
The phone Dto is:
using Abp.AutoMapper;
using Abp.Application.Services.Dto;
namespace stake.Partners.Dto
{
[AutoMap(typeof(Phone))]
public class PartnerPhoneDto : EntityDto
{
public string Name { get; set; }
public int PartnerId { get; set; }
public int PhoneTypeId { get; set; }
}
}
I would say yes, as I made so many attempts, but I try it again and I tell you.
I was using those, but probably I had issues with my Dtos. Now Everything is working fine. Thanks!
I confirm the issue on that part is that you have to replace $modal with $uibModal in both the modal controller and the index one. Look at:
$modal has been renamed to $uibModal in ui-bootstrap 0.14.0: [https://github.com/olov/ng-annotate/issues/200])