2016-03-27 8 views
0
public List<PropertyListDto> GetPropertiesByStatus(GetPropertyInput input) 
     { 

      //exception occurs here 
      var properties = _propertyRepository 
       .GetAll() 
       .Include(p => p.Address) 
       .ToList(); 

      var results = new List<PropertyListDto>(properties.OrderBy(p => p.Id).MapTo<List<PropertyListDto>>()); 
      return results; 

     } 



[AutoMapFrom(typeof(Property))] 
    public class PropertyListDto : FullAuditedEntityDto 
    { 
     public new int Id { get; set; } 
     public CountyListDto County { get; set; } 
     public string Priority { get; set; } 
     public string Dist { get; set; } 
     public decimal ListingPrice { get; set; } 
     public string Blk { get; set; } 
     public AddressDto Address { get; set; } 
     public string Contact { get; set; } 
     public string Lot { get; set; } 
     public decimal Taxes { get; set; } 
     public string Mls { get; set; } 
     public ICollection<CommentEditDto> Comments { get; set; } 
     public int? LegacyId { get; set; } 
    } 

Q çok büyük verileri göstermek için: Açısal UI 100.000 (1 yüz bin) veri sorunudur Grid.But etrafında ben göstermek gerekir söyleyebilir olabilir sorgu bellek exception.So verir yukarıda bu sorunu nasıl çözebilirim? Teşekkürler.ui ızgarada

Not: Ben .AsNoTracking() kullandığınızda

, o zaman ilk sorguyu çalışıyor: Ben pagination.So olmadan veri göstermek gerekir Bu UI Grid.

GÜNCELLEME seçtiniz.

var properties = _propertyRepository 
       .GetAll() 
       .AsNoTracking() 
       .Include(p => p.Address) 
       .ToList(); 

Ama sonra sorun nasıl dışarı sıralamak için söyle MapTo line.Could var? Teşekkürler.

{"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."} 

Mapping types: 
Property_A048C3D093990BB6A086B710BAC90CB35FD4BAB180FC02FA3E90053FE58F20D3 -> ICollection`1 
System.Data.Entity.DynamicProxies.Property_A048C3D093990BB6A086B710BAC90CB35FD4BAB180FC02FA3E90053FE58F20D3 -> System.Collections.Generic.ICollection`1[[IP.Comments.Dtos.CommentEditDto,IP.Application, Version=1.7.1.1, Culture=neutral, PublicKeyToken=null]] 

Destination path: 
List`1[3126].Comments3126[3126].Comments3126[3126] 

Source value: 
[Property_A048C3D093990BB6A086B710BAC90CB35FD4BAB180FC02FA3E90053FE58F20D3 3166] 

GÜNCELLEME 2: Ben Dto nesnesine EF nesne eşleştirmek için Automapper kullandık İşte

var results = new List<PropertyListDto>(properties.OrderBy(p => p.Id).MapTo<List<PropertyListDto>>());//error is here now 

Bu

hatadır.

cevap

1

MapTo'nun ne yaptığını bilmediğim için iki ToList yöntemini başlatıyorsunuzdur. Ancak bunun yerine doğrudan dto seçmek eşleme yapıyor:

var properties = _propertyRepository 
       .GetAll() 
       .AsNoTracking() 
       .Include(p => p.Address). 
       .Select(s=> new PropertyListDto{ 
         Id = s.Id 
         CountyListDto = s.CountyListDto 
         ...  


}) 

OP'ın Cevap: Tüm now.Cheers de Aslında azalttık tüm yukarıdaki tabloda gereksiz veri ve şimdi etrafında 1K geçiriyor + records.So hiçbir sorun :)

+0

Burada EF nesnesini Dto nesnesiyle eşleştirmek için Automapper'ı kullandım.Teşekkürler. – Sampath

+0

Aslında yukarıdaki haritalama (benim yazı üzerine) az sayıda kayıt ile iyi çalışıyor. Sorun büyük kayıtlar kümesidir. Teşekkürler. – Sampath

+0

Çünkü haritalamada bir listeyle başa çıkıyorsunuz. Kodumu veya Otomatik Kalıcı Queryable Uzantılarımı kullanmayı deneyin https://github.com/AutoMapper/AutoMapper/wiki/Queryable-Extensions –