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

Activities of "exlnt"

I tried your idea, and set the PK to "long" (Int64) on the DTO and Entity. Still I get the same error?

AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types:
Company -> EditCompanyDto
NursingOps.Company -> NursingOps.Dto.EditCompanyDto

Type Map configuration:
Company -> EditCompanyDto
NursingOps.Company -> NursingOps.Dto.EditCompanyDto

Property:
Contacts ---> AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.

Mapping types:
CompanyContact -> EditContactDto
NursingOps.CompanyContact -> NursingOps.Dto.EditContactDto
   at lambda_method(Closure , CompanyContact , EditContactDto , ResolutionContext )
   at AutoMapper.ResolutionContext.Map[TSource,TDestination](TSource source, TDestination destination)
   at lambda_method(Closure , Object , Object , ResolutionContext )
   --- End of inner exception stack trace ---
   at lambda_method(Closure , Object , Object , ResolutionContext )
   at AutoMapper.Mapper.AutoMapper.IMapper.Map[TDestination](Object source)
   at AutoMapper.Mapper.Map[TDestination](Object source)
   at Abp.AutoMapper.AutoMapExtensions.MapTo[TDestination](Object source) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.AutoMapper\AutoMapper\AutoMapExtensions.cs:line 15
   at NursingOps.CompanyAppService.d__9.MoveNext() in \Application\NursingOps\CompanyAppService.cs:line 79
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Threading.InternalAsyncHelper.d__5`1.MoveNext() in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs:line 120
--- End of stack...

Can you be more specific on which ones i need to add this to?

I added it to EditContactDto, EditAddressDto and EditCompanyDto. After that I still get the same kind of error, see below.

AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types:
Company -> EditCompanyDto
NursingOps.Company -> NursingOps.Dto.EditCompanyDto

Type Map configuration:
Company -> EditCompanyDto
NursingOps.Company -> NursingOps.Dto.EditCompanyDto

Property:
Contacts ---> AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.

Mapping types:
CompanyContact -> EditContactDto
NursingOps.CompanyContact -> NursingOps.Dto.EditContactDto
   at lambda_method(Closure , CompanyContact , EditContactDto , ResolutionContext )
   at AutoMapper.ResolutionContext.Map[TSource,TDestination](TSource source, TDestination destination)
   at lambda_method(Closure , Object , Object , ResolutionContext )
   --- End of inner exception stack trace ---
   at lambda_method(Closure , Object , Object , ResolutionContext )
   at AutoMapper.Mapper.AutoMapper.IMapper.Map[TDestination](Object source)
   at AutoMapper.Mapper.Map[TDestination](Object source)
   at Abp.AutoMapper.AutoMapExtensions.MapTo[TDestination](Object source) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.AutoMapper\AutoMapper\AutoMapExtensions.cs:line 15
   at NursingOps.CompanyAppService.d__9.MoveNext() in Application\NursingOps\CompanyAppService.cs:line 79
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Threading.InternalAsyncHelper.d__5`1.MoveNext() in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs:line 120
--- End of stack...

Now I have new issue related to this relationship setup.

When the company app service method "GetCompanyForEdit" is called, it returns all the company data plus the addresses and contacts for the selected company. But when the method executes the MapTo<> statement, an exception is thrown.

This file shows all the code and the error message: [https://drive.google.com/open?id=0BzbrPy41GhA4TmoxNnJIeV9IMFk])

By adding the below changes, I was able to make the relationship work. I also did not have to add another migration for this change.

public virtual List<CompanyAddress> Addresses { get; set; }

        public virtual List<CompanyContact> Contacts { get; set; }

        public Company()
        {
            Addresses = new List<CompanyAddress>();
            Contacts = new List<CompanyContact>();
        }

I made the above code change after reading this article: [http://www.entityframeworktutorial.net/code-first/configure-one-to-many-relationship-in-code-first.aspx])

They are already in my table, see below.

[attachment=0:13vf8zqo]Screenshot (42).png[/attachment:13vf8zqo]

Hi @ismcagdas...Thank you that worked!

I am very interested in doing the same thing. My application displays create date + create user name and modified date + modified user name on every entity UI page.

For the index/list view I was able to use the below code, from an ABP example. This joins to the user table and puts the name into my custom "createusername" column in my Dto.

private IQueryable<CompanyUserAndAllFK> CompanyListingQuery(GetCompanyInput input)
        {
            var query = from cmp in _companyRepository.GetAllCompanies()
                        join listval in _listvaluesRepository.GetAll() on cmp.CurrencyCode equals listval.ListValue
                        join user in _userRepository.GetAll() on cmp.CreatorUserId equals user.Id into userJoin
                        from joinedUser in userJoin.DefaultIfEmpty()
                        select new CompanyUserAndAllFK { Company = cmp, User = joinedUser, ListValues = listval };

            query = query
                .WhereIf(!input.Filter.IsNullOrWhiteSpace(), comp => comp.Company.CompanyName.Contains(input.Filter) || comp.Company.CompanyLegalName.Contains(input.Filter) );
            return query;
        }

I hope this helps?

I was able to find one solution. I added line 1 below just before the "MapTo" and that is allowing me to get the "Id" for Note.

input.Note.Id = (int)cmp.Note.Id;
     input.MapTo(cmp);
     await _companyRepository.UpdateAsync(cmp);

Please let me know if there is an alternate to this solution. I would prefer the view model send it back to the app service. Thanks!

I have sent you email.

Here is the original code in my Sidebar.cshtml

//Using statements here
@{
    var calculateMenuUrl = new Func<string, string>((url) =>
    {
        if (string.IsNullOrEmpty(url))
        {
            return ApplicationPath;
        }

        if (UrlChecker.IsRooted(url))
        {
            return url;
        }

        return ApplicationPath + url;
    });
}
<div class="page-sidebar navbar-collapse collapse">
    
    
    
    
    
    
    <ul class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
        @for (var i = 0; i < Model.Menu.Items.Count; i++)
        {
            var menuItem = Model.Menu.Items[i];

            <li class="@(i==0 ? "start" : "") @(menuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
                @if (menuItem.Items.IsNullOrEmpty())
                {
                    <a href="@calculateMenuUrl(menuItem.Url)">
                        <i class="@menuItem.Icon"></i>
                        <span class="title">@menuItem.DisplayName</span>
                    </a>
                }
                else
                {
                    <a href="javascript:;" class="auto">
                        <i class="@menuItem.Icon"></i>
                        <span class="title">@menuItem.DisplayName</span>
                        <span class="arrow"></span>
                    </a>
                    <ul class="sub-menu">
                        @foreach (var childMenuItem in menuItem.Items)
                        {
                            <li class="@(childMenuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
                                @if (childMenuItem.Items.IsNullOrEmpty())
                                {
                                    <a href="@calculateMenuUrl(childMenuItem.Url)">
                                        <span><i class="sub-menu-icon @childMenuItem.Icon"></i> @childMenuItem.DisplayName</span>
                                    </a>
                                }
                                else
                                {
                                    <a href="javascript:;" class="auto">
                                        <i class="@childMenuItem.Icon"></i>
                                        <span class="title">@childMenuItem.DisplayName</span>
                                        <span class="arrow"></span>
                                    </a>
                                    <ul class="sub-menu">
                                        @foreach (var secondLevelChildMenuItem in childMenuItem.Items)
                                        {
                                            <li class="@(secondLevelChildMenuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
                                                <a href="@calculateMenuUrl(secondLevelChildMenuItem.Url)">
                                                    <span><i class="sub-menu-icon @secondLevelChildMenuItem.Icon"></i> @secondLevelChildMenuItem.DisplayName</span>
                                                </a>
                                            </li>
                                        }
                                    </ul>
                                }
                            </li>
                        }
                    </ul>
                }
            </li>
        }
    </ul>

</div>

I changedthese lines: <a href="javascript:;" class="auto"> to <a href="javascript:;" class="auto nav-link nav-toggle">

And it still did not work or fix the menu issue?

Also when i check my developer tools in chrome browser there are no JS related errors, before or after click on menu item.

Showing 221 to 230 of 263 entries