我正在使用此代码,但无效
List<UrunListesi> DegiskenListesi = new List<UrunListesi>();
DegiskenUrunListesi = (from UL in DB.UrunListesi
where IDListesi.Contains(UL.KategoriID.ToString()) && UL.Durum == true
orderby UL.id descending
select UL).ToList();
浏览器错误
“CS0029:无法隐式转换类型
System.Collections.Generic.List<UrunListesi>
[c:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ mscorlib.dll]'到System.Collections.Generic.List<UrunListesi>
[C:\的Windows \ Microsoft.NET \框架\ v4.0.30319 \ mscorlib.dll中]'“
我试过这条线,但这也行不通了
IEnumerable<UrunListesi> DegiskenUrunListesi = null;
DegiskenUrunListesi = (from UL in DB.UrunListesi
where IDListesi.Contains(UL.KategoriID.ToString()) && UL.Durum == true
orderby UL.id descending
select UL).ToList();
的DbContext
public partial class MySiteDBEntities : DbContext
{
public MySiteDBEntities()
: base("name=MySiteDBEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<AnaBanner> AnaBanner { get; set; }
public virtual DbSet<BankaListesi> BankaListesi { get; set; }
public virtual DbSet<KategoriListesi> KategoriListesi { get; set; }
public virtual DbSet<KrediKartiOdemeleri> KrediKartiOdemeleri { get; set; }
public virtual DbSet<TaksitOranTablosu> TaksitOranTablosu { get; set; }
public virtual DbSet<UrunResimListesi> UrunResimListesi { get; set; }
public virtual DbSet<UrunYorumlari> UrunYorumlari { get; set; }
public virtual DbSet<MarkaListesi> MarkaListesi { get; set; }
public virtual DbSet<IlceListesi> IlceListesi { get; set; }
public virtual DbSet<SehirListesi> SehirListesi { get; set; }
public virtual DbSet<UlkeListesi> UlkeListesi { get; set; }
public virtual DbSet<UyeBilgileri> UyeBilgileri { get; set; }
public virtual DbSet<KullaniciListesi> KullaniciListesi { get; set; }
public virtual DbSet<SepetListesi> SepetListesi { get; set; }
public virtual DbSet<BinListesi> BinListesi { get; set; }
public virtual DbSet<RenkListesi> RenkListesi { get; set; }
public virtual DbSet<UrunListesi> UrunListesi { get; set; }
}
UrunListesi Class
public partial class UrunListesi
{
public int id { get; set; }
public Nullable<int> MarkaID { get; set; }
public Nullable<int> KategoriID { get; set; }
public string UrunAdi { get; set; }
public string UrunKodu { get; set; }
public string UrunAciklama { get; set; }
public string AnaResim { get; set; }
public Nullable<decimal> Fiyat { get; set; }
public Nullable<bool> Indirimli { get; set; }
public Nullable<decimal> IndirimliFiyat { get; set; }
public Nullable<int> Kdv { get; set; }
public Nullable<bool> Iskontolu { get; set; }
public Nullable<int> IskontoOrani { get; set; }
public Nullable<int> StokAdet { get; set; }
public Nullable<int> RenkID { get; set; }
public Nullable<bool> EviminoImalati { get; set; }
public Nullable<bool> KargoBedava { get; set; }
public Nullable<decimal> KargoFiyati { get; set; }
public Nullable<int> KargoSuresi { get; set; }
public Nullable<bool> FirsatUrunu { get; set; }
public Nullable<System.DateTime> FirsatBaslangicTarihi { get; set; }
public Nullable<System.DateTime> FirsatBitisTarihi { get; set; }
public Nullable<bool> KampanyaliUrun { get; set; }
public Nullable<System.DateTime> KampanyaBitis { get; set; }
public Nullable<int> UrunHit { get; set; }
public Nullable<System.DateTime> KayitTarih { get; set; }
public Nullable<bool> Durum { get; set; }
public Nullable<System.Guid> UrunKey { get; set; }
}
需要帮助,谢谢。
答案 0 :(得分:0)
我解决了这个问题。
我在dbcontext中有UrunListesi类。我有同名UrunListesi.aspx文件。这就是整个问题。
感谢所有回答。
答案 1 :(得分:-1)
尝试:
var list = (from UL in DB.UrunListesi
where IDListesi.Contains(UL.KategoriID.ToString()) && UL.Durum == true
orderby UL.id descending
select UL).ToList();