I'm trying to figure out a way of mapping an icollection into a table but it throws me this errors:
Error 1:
Cannot implicitly convert type 'System.Collections.Generic.ICollection' to 'elayer.c'. An explicit conversion exists (are you missing a cast?)
Error 2:
Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type EntityLayer
This is part of the code, if needed more for help would love to add, it's driving me crazy,
Mapping.cs
internal class CMapping : EntityTypeConfiguration<c>
{
internal CMapping()
{
this.Property(x => x.Name).HasMaxLength(200);
this.HasMany(x => x.wc)
.WithRequired(x => x.c)
.HasForeignKey(x => x.cid);
}
}
c.cs
public class c: BaseEntity
{
public int cid{ get; set; }
public string Name { get; set; }
public string Text { get; set; }
public int link{ get; set; }
public ctype Type { get; set; }
public ICollection <wc> wcs{ get; set; }
}
wc.cs
public class wc: BaseEntity
{
public int wcid { get; set; }
public int wid{ get; set; }
public int cid{ get; set; }
public int BrandId { get; set; }
public w w{ get; set; }
public virtual ICollection<c> c{ get; set; }
}
UPDATE ----- wcQueryService
public IEnumerable<wDto> FindwcByStoreIdAndwId(int storeId, int wId)
{
using (var dc = this._cmsContextFactory())
{
var query = from wc in dc.wc
join c in dc.c on wc.wId equals c.wId
join w in dc.w on wc.wId equals w.wId
where wc.IsDeleted == false
&& c.IsDeleted == false
&& wc.IsDeleted == false
&& wc.BrandId == storeId
&& w.wId == wId
select new wDto
{
wwId = wc.wwId,
wId = w.wId,
wId = c.wId,
BrandId = wc.BrandId,
Videos = (from c in wc.w
select new wTypeVideoDto
{
Text = c.Text,
wId = c.wId
}).ToList()
};
return query.ToList();
}
}