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

Activities of "itzoar2"

Hi Aaron

I have changed the the below LINQ

but it seems the output still cannot get the ProductApprovals object

I have attached the Domain Entity for your reference too. please advise. Thanks a lot

        var output = from p in
            (_productRepo.GetAllIncluding(
                     p => p.Colour,
                     p => p.Unit,
                     p => p.Serie,
                     p => p.Brand,
                     p => p.Supplier,
                     p => p.ProductCategory1,
                     p => p.ProductCategory2,
                     p => p.ProductCategory3,
                     p => p.ProductCategory4,
                     p => p.MinQuantities,
                     p => p.CreatorUser,
                     p => p.CreatorUser.Company
            ).Include(p => p.ProductApprovals) // Include relationship
                .ThenInclude(pa => pa.Approver1) // ThenInclude nested relationship
            .ToList())
                     where Filter.FilterUtil.FilterForGetProduct(p, input)
                     select p;

I find that the GetAllIncluding is not stable

The below is the code that i link all related object out

but from my screenshot, you can see sometimes it can map to the object ProductApproval.Approver1 and sometimes i can't.

Is it because my apsnetboilerplate framework is on version 2.0.2?

should i update to the latest aspnetboilerplate framework?

private IEnumerable<Product> GetProduct(FilterInput input)
        {
            var output = from p in
                     (_productRepo.GetAllIncluding(
                     p => p.Colour,
                     p => p.Unit,
                     p => p.Serie,
                     p => p.Brand,
                     p => p.Supplier,
                     p => p.ProductCategory1,
                     p => p.ProductCategory2,
                     p => p.ProductCategory3,
                     p => p.ProductCategory4,
                     p => p.MinQuantities,
                     p => p.ProductApprovals,
                     p => p.CreatorUser,
                     p => p.CreatorUser.Company
                    ).ToList())
                         where Filter.FilterUtil.FilterForGetProduct(p, input)
                         select p;

            return output;
        }

I am now using the Aspnet Boilerplate framework

may i know how to debug the Entity Framework now ?

if i want to check the SQL statement generate by EF, where should i configure now ? Thanks

Answer

Thanks my problem is solved

Also, it is fine, my data is small , so performance should be ok. THanks

Answer

if i break down to 2 linq query, it will work

                var query = (from q in _clientRepository.GetAllIncluding(dd => dd.Counterparty, ee => ee.ClientContact)
                             select q).ToList();


                query = (from c in query
                         join ct in _companyTypeRepository.GetAllList() on c.Type_Id equals ct.Id into allType
                         from c1 in allType.DefaultIfEmpty()
                         join bn in _businessNatureRepository.GetAllList() on c.Nature_Id equals bn.Id into allNature
                         from c2 in allNature.DefaultIfEmpty()
                         join pm in _clientContactRepository.GetAllList() on c.PurchaseManager_Id equals pm.Id into allPMgr
                         from c3 in allPMgr.DefaultIfEmpty()
                         join pp in _clientContactRepository.GetAllList() on c.PurchasePerson_Id equals pp.Id into allPPerson
                         from c4 in allPPerson.DefaultIfEmpty()
                         join cp in _userRepository.GetAllList() on c.ContactPerson_Id equals cp.Id into allContactPerson
                         from c5 in allContactPerson.DefaultIfEmpty()
                         select c).ToList();
Answer

Hi

Now when i try to do a left outer join with other repo,

The GetAllIncluding doesn't work

if i don't have the join, it works like a champ?

Do you have any idea? Thanks

                var query = (from c in _clientRepository.GetAllIncluding(co => co.Counterparty, cc => cc.ClientContact)
                             join ct in _companyTypeRepository.GetAll() on c.Type_Id equals ct.Id into allType
                             from c1 in allType.DefaultIfEmpty()
                             join bn in _businessNatureRepository.GetAll() on c.Nature_Id equals bn.Id into allNature
                             from c2 in allNature.DefaultIfEmpty()
                             join pm in _clientContactRepository.GetAll() on c.PurchaseManager_Id equals pm.Id into allPMgr
                             from c3 in allPMgr.DefaultIfEmpty()
                             join pp in _clientContactRepository.GetAll() on c.PurchasePerson_Id equals pp.Id into allPPerson
                             from c4 in allPPerson.DefaultIfEmpty()
                             join cp in _userRepository.GetAll() on c.ContactPerson_Id equals cp.Id into allContactPerson
                             from c5 in allContactPerson.DefaultIfEmpty()
                             select c).ToList();
Answer

seems like if i want to include 2 different collection list

i should use from c in _clientRepository.GetAllIncluding(client => client.Counterparty , bb =>bb.ContactPerson)

Answer

What if i also want to include counterparty ? Use &&?

Question

Hi all

My Domain is in

[Table("Client")] public class Client : FullAuditedEntity<int,User> { public string Name { get; set; } public string NameEn { get; set; } public string ShortName { get; set; } public string Address { get; set; } public string AddressEn { get; set; } public string Website { get; set; } public string SocialCreditCode { get; set; } public DateTimeOffset? Registration { get; set; } public DateTimeOffset? ValidUntil { get; set; } public decimal? OperationYear { get; set; } public decimal? Capital { get; set; } public string Representative { get; set; } public string MainProduct { get; set; } public int? CheckDate { get; set; }

    [ForeignKey("Type_Id")]
    public CompanyType Type { get; set; }
    public int? Type_Id { get; set; }

    [ForeignKey("Nature_Id")]
    public BusinessNature Nature { get; set; }
    public int? Nature_Id { get; set; }

    [ForeignKey("PurchasePerson_Id")]
    public ClientContact PurchasePerson { get; set; }
    public int? PurchasePerson_Id { get; set; }

    [ForeignKey("PurchaseManager_Id")]
    public ClientContact PurchaseManager { get; set; }
    public int? PurchaseManager_Id { get; set; }

    [ForeignKey("ContactPerson_Id")]
    public User ContactPerson { get; set; }
    public long? ContactPerson_Id { get; set; }

    public List&lt;Counterparty&gt; Counterparty { get; set; }
    public List&lt;ClientContact&gt; ClientContact { get; set; }
    public bool Disuse { get; set; }

For the service layer, how do i get a GetAllClient LINQ , if i have one to many relationship between Client and Counterparty.

Please advise. Thanks a lot

How about the Service layer and the DTO ?

can i have some example ?

Showing 11 to 20 of 21 entries