entity-framework

IQueryable extension method for linq2entities

本小妞迷上赌 提交于 2020-01-09 09:43:19
问题 I am trying to implement an extension method that will work with linq2entities. I had initially assumed that if my extension method took and returned an IQueryable, and as long as my expression only made use of supported methods, then it would work fine. I was having alot of trouble, so as a last resort I copied an existing .NET extension method that I knew to work(FirstOrDefault) and simply renamed it. It would seem like it would evaluate the "cannot be translated into a store expression"

IQueryable extension method for linq2entities

删除回忆录丶 提交于 2020-01-09 09:42:30
问题 I am trying to implement an extension method that will work with linq2entities. I had initially assumed that if my extension method took and returned an IQueryable, and as long as my expression only made use of supported methods, then it would work fine. I was having alot of trouble, so as a last resort I copied an existing .NET extension method that I knew to work(FirstOrDefault) and simply renamed it. It would seem like it would evaluate the "cannot be translated into a store expression"

IQueryable extension method for linq2entities

天大地大妈咪最大 提交于 2020-01-09 09:41:25
问题 I am trying to implement an extension method that will work with linq2entities. I had initially assumed that if my extension method took and returned an IQueryable, and as long as my expression only made use of supported methods, then it would work fine. I was having alot of trouble, so as a last resort I copied an existing .NET extension method that I knew to work(FirstOrDefault) and simply renamed it. It would seem like it would evaluate the "cannot be translated into a store expression"

EntityFramework Eager Load all Navigation Properties

亡梦爱人 提交于 2020-01-09 09:15:32
问题 I'm using the Repository pattern with DI and IoC. I have created a function in my Repository: T EagerGetById<T>(Guid id, string include) where T : class { return _dbContext.Set<T>().Include(include).Find(id); } This will eagerly load one navigation property in my entity right. But if my entity looks like this: public class Blog : PrimaryKey { public Author Author {get;set;} public ICollection<Post> Posts {get;set;} } How would I get eager loading for Author and Posts ? Would I literally have

Can I mix Table per Hierarchy and Table per Type in Entity Framework?

本小妞迷上赌 提交于 2020-01-09 08:08:06
问题 Say I have 2 tables: Message and SuperMessage and 3 entities: Message (base (not abstract)), Comment (inherits from Message) and SuperMessage (inherits from Message) Message has a non-nullable MessageType field which is used as a discriminator. MessageType = 1 means it is a Message MessageType = 2 means it is a Comment MessageType = 3 AND and join to the SuperMessage means it is a SuperMessage The problem is that I cannot specify a condition on MessageType of the SuperMessage's Mapping

Entity Framework Delete Object Problem

时光毁灭记忆、已成空白 提交于 2020-01-09 07:55:30
问题 i am getting "The object cannot be deleted because it was not found in the ObjectStateManager". while Deleting object. here is codes ; //first i am filling listview control. private void Form1_Load(object sender, EventArgs e) { FirebirdEntity asa = new FirebirdEntity(); ObjectQuery<NEW_TABLE> sorgu = asa.NEW_TABLE; foreach (var item in sorgu) { ListViewItem list = new ListViewItem(); list.Text = item.AD; list.SubItems.Add(item.SOYAD); list.Tag = item; listView1.Items.Add(list); } //than

Entity Framework Delete Object Problem

时光怂恿深爱的人放手 提交于 2020-01-09 07:55:09
问题 i am getting "The object cannot be deleted because it was not found in the ObjectStateManager". while Deleting object. here is codes ; //first i am filling listview control. private void Form1_Load(object sender, EventArgs e) { FirebirdEntity asa = new FirebirdEntity(); ObjectQuery<NEW_TABLE> sorgu = asa.NEW_TABLE; foreach (var item in sorgu) { ListViewItem list = new ListViewItem(); list.Text = item.AD; list.SubItems.Add(item.SOYAD); list.Tag = item; listView1.Items.Add(list); } //than

What is the default transaction isolation level in Entity Framework when I issue “SaveChanges()”?

佐手、 提交于 2020-01-09 06:51:10
问题 What is the default transaction isolation level in Entity Framework when I issue “SaveChanges()”? I can not find it anywhere. Shall it be "Serializable"? 回答1: SaveChanges uses implementation of DbTransaction for current store provider. It means that default transaction isolation level is set to default value for the database server. In SQL Server it is READ COMMITTED . If you want to change isolation level you can use TransactionScope . You can also override SaveChanges in your derived

Entity Framework Query for inner join

霸气de小男生 提交于 2020-01-09 06:11:38
问题 What would be the query for: select s.* from Service s inner join ServiceAssignment sa on sa.ServiceId = s.Id where sa.LocationId = 1 in entity framework? This is what I wrote: var serv = (from s in db.Services join sl in Location on s.id equals sl.id where sl.id = s.id select s).ToList(); but it's wrong. Can some one guide me to the path? 回答1: from s in db.Services join sa in db.ServiceAssignments on s.Id equals sa.ServiceId where sa.LocationId == 1 select s Where db is your DbContext .

Entity Framework Query for inner join

 ̄綄美尐妖づ 提交于 2020-01-09 06:05:15
问题 What would be the query for: select s.* from Service s inner join ServiceAssignment sa on sa.ServiceId = s.Id where sa.LocationId = 1 in entity framework? This is what I wrote: var serv = (from s in db.Services join sl in Location on s.id equals sl.id where sl.id = s.id select s).ToList(); but it's wrong. Can some one guide me to the path? 回答1: from s in db.Services join sa in db.ServiceAssignments on s.Id equals sa.ServiceId where sa.LocationId == 1 select s Where db is your DbContext .