Base solution for your next web application

Activities of "dougmorato"

Question

We are trying to develop a product using latest Angular SPA version of aspnetzero. Can you please provide some working sample of editable grid/table. From demo UI component of the base solution , we have got lots help for other controls but not finding any suitable option for editable grid/table.

Have you got any any solution? I need FullAuditedEntity in child tables also. But the application is throwing error during update.

But the main issue is not resolved . You will get the same error if you inherit the child table from FullAuditedEntity. The sample you have provide the child is inheriting from AuditedEntity<int> not FullAuditedEntity.

You will get the same error if you inherit the child table from FullAuditedEntity. By following your code I have also changed the child table and it working then. But I need the audit columns, soft delete in the child table also.

Also in your code, if we delete a child object from child collection it is not affecting the database. But if we updating any child property is reflecting in the database. Should we have to manually identify deleted children and then delete those within a loop by calling the delete method of child repository?

The issue has been resolved.

Thanks a lot.

Please find the sample code below.

`public class CreateOrEditParentDto : EntityDto&lt;int?&gt; { 		
[Required] 		public string ParentName { get; set; } 	
public ICollection&lt;CreateOrEditChildDto&gt; Children { get; set; } }`
 public class CreateOrEditChildDto : EntityDto<int?>
    {
		[Required]
		public string Email { get; set; }
		public string FirstName { get; set; }
		public string LastName { get; set; }
		public int ParentId { get; set; }
}

The core classes are like below

 [Table("Parent")]
    public class Parent : FullAuditedEntity , IMustHaveTenant
    {
		public int TenantId { get; set; }
		[Required]
		public virtual string ParentName { get; set; }
		public virtual ICollection<Child> Children { get; set; }
}
[Table("Child")]
    public class Child : FullAuditedEntity , IMustHaveTenant
    {
	   public int TenantId { get; set; }
		[Required]
		public virtual string Email { get; set; }		
		public virtual string FirstName { get; set; }		
		public virtual string LastName { get; set; }
		public virtual int ParentId { get; set; }	
         [ForeignKey("ParentId")]
		public Parent ParentFk { get; set; }
	}

We have just started developing a new product using ASPNetZero 9.1 Angular version. But I have doubts regarding the CRUD operation of entities with multiple parent-child relations.

We have a “Parent” entity that contains a collection of “Child” entities. The “Child” table has the foreign key of parent ID.

Now as per the requirement when updating parent user update/delete any existing child or add a new child.

By following the Tutorial, I have tried with the below code. But it is throwing error “Child cannot be tracked because another instance with the same key value for {'Id'}”

<br>

protected virtual async Task Update(CreateOrEditParentDto input)
{
var parent = await _parentRepository.GetAllIncluding(v => v.children)
.FirstOrDefaultAsync(v => v.Id == (int)input.Id);
ObjectMapper.Map(input, parent);
}

<br> I have tried insert, delete children within for loop. But that is also throwing error.  I have found multiple links similar kind of issue but none of the solutions able to fix this issue.

What is the best way to add/update/delete all child entities with the same transaction?  A similar code works perfectly for the insert.

We have just started developing a new product using ASPNetZero 9.1 Angular version. But I have doubts regarding the CRUD operation of entities with multiple parent-child relations. We have a “Parent” entity that contains a collection of “Child” entities. The “Child” table has the foreign key of parent ID. Now When deleting one “Parent”, I want to delete all the associated children. I don’t want to enable cascade delete at the DB level. To achieve this first I have deleted all the children and removed the parent. Please the pseudo-code below

Is it the optimal way to achieve this requirement? Actually, I am concern about the performance impact of calling child repository within the loop, there many huge numbers of children.

`[AbpAuthorize(AppPermissions.PagesParentDelete)] public async Task Delete(EntityDto input) { var parent = await parentRepository.GetAllIncluding(v => v.Children) .FirstOrDefaultAsync(v => v.Id == (int)input.Id); foreach (var child in parent.Children) { await childRepository.DeleteAsync(child.Id); } await _parentRepository.DeleteAsync(input.Id); }`

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version?
  • v9.10
  • What is your product type (Angular or MVC)?
  • angular
  • What is product framework type (.net framework or .net core)?
  • ,net core

I have generated multiple screens using the Visual Studio Extension Aspnetzero power tool. But suddenly it stopped working.

I have uninstalled and installed the RAD tool. I have recreated my code repo. But it not at all working. After creating generate button it closes automatically after few seconds.

Please guide us to troubleshoot and fix this issue.

Showing 1 to 10 of 16 entries