I'm using EntityFramework 4.3.1 and trying to run a query like this
Context.Set<KullaniciYetkiView>().Where(y => y.KullaniciId == kullaniciId && y.YetkiKod == yetkiKod)
When i run the query and it returns 115 records as expected. But when i look the record all of them is same. So i listen the query from profiler for to look what am i missing, is see the below query and its return 115 different records from management studio.
exec sp_executesql N'SELECT
[Extent1].[YetkiKod] AS [YetkiKod],
[Extent1].[KullaniciId] AS [KullaniciId],
[Extent1].[LokasyonId] AS [LokasyonId],
[Extent1].[YetkiId] AS [YetkiId],
[Extent1].[HiyerarsikKod] AS [HiyerarsikKod],
[Extent1].[LokasyonSeviye] AS [LokasyonSeviye],
[Extent1].[Yetkili] AS [Yetkili],
[Extent1].[Engelli] AS [Engelli],
[Extent1].[LokasyonEngelli] AS [LokasyonEngelli]
FROM [dbo].[sayKullaniciYetkiView] AS [Extent1]
WHERE ([Extent1].[KullaniciId] = @p__linq__0) AND ([Extent1].[YetkiKod] = @p__linq__1)',N'@p__linq__0 uniqueidentifier,@p__linq__1 nvarchar(4000)',@p__linq__0='283CCB41-3BDF-4BEF-BD26-E46191CA069D',@p__linq__1=N'FIN.SATISFATURA.E'
I think the problem is in EF and to prove it I run the code like this
var yetkiler1 = Context.Set<KullaniciYetkiView>().Where(y => y.KullaniciId == kullaniciId && y.YetkiKod == yetkiKod).Distinct().ToList();
var yetkiler2 = Context.Set<KullaniciYetkiView>().Where(y => y.KullaniciId == kullaniciId && y.YetkiKod == yetkiKod).ToList().Distinct();
First query returns 115 rows and the second returns 1.
What am I missing?
Thanks in advance.