entity-framework-4

Auditing a Table with EF Code first

强颜欢笑 提交于 2020-01-15 10:39:28
问题 I have a class say Message like following: public class Message { public int Id{get;set;} public string MessageText{get;set;} public int Sender{get;set;} public DateTime CreatedOn{get;set;} //EDIT:2 public virtual Message RepliedTo{get;set;} public virtual IList<Message> Replies{get;set;} public virtual IList<MessageStatusHistory> History{get;set;} //so on and so forth } Now I want to keep statuses of the Message object like what user marked it as read and when. I created a class

Entity Framework deadlock problem

那年仲夏 提交于 2020-01-15 08:43:25
问题 I'm having a strange problem with new Entity Framework for .NET 4 I have a SQL Server 2005 (EXPRESS) database and my service writes data to two tables using entity framework. Let's say tables are TableA and TableB. TableB has foreign key to TableA. In my program there are several threads that writes data in parallel. Each thread has its own ObjectContext. The program creats TableA object and puts it in the object context. Then objects for TableB are created and put to object context. This

Display image from database in _layout in mvc4

馋奶兔 提交于 2020-01-14 14:45:34
问题 Hi all I am having my _layout as follows which works as per my requirement, but here there are couple of things I got strucked i.e I would like to display the corresponding image for that I write as follows @if (Session["UserName"] != null) { <div class="logged_in" id="user_navigation" runat="server"> <a title="Your Profile" href=""> <img alt="" src="@Url.Action("GetPhoto", new { photoId = Session["UserName"] })" height="50" width="50" class="photo" /> </a> </div> } But this is not showing

Display image from database in _layout in mvc4

我们两清 提交于 2020-01-14 14:45:08
问题 Hi all I am having my _layout as follows which works as per my requirement, but here there are couple of things I got strucked i.e I would like to display the corresponding image for that I write as follows @if (Session["UserName"] != null) { <div class="logged_in" id="user_navigation" runat="server"> <a title="Your Profile" href=""> <img alt="" src="@Url.Action("GetPhoto", new { photoId = Session["UserName"] })" height="50" width="50" class="photo" /> </a> </div> } But this is not showing

How to get EFProf and EFProviderWrapper working together in on Entity Framework Connection

北城以北 提交于 2020-01-14 10:14:07
问题 Has anyone found a way to get Kowalski's EFProviderWrapper framework to run alongside Rhino's EFProf (Entity Framework Profiler) within the same Entity Framework context/connection? Currently if i try to register the EFProf Profiler while using an EntitytConnection wrapped with the EFProviderWrapper i get the following error at runtime when a new connection is attempted to be created: Unable to cast object of type 'HibernatingRhinos.Profiler.Appender.ProfiledDataAccess.ProfiledConnection' to

No generic method 'OrderBy' on type 'Queryable' is compatible with the supplied type arguments

﹥>﹥吖頭↗ 提交于 2020-01-14 09:32:15
问题 I'm writing some code that will modify an expression so that the subquery contained in it will get ordered. I found a similar piece of code here on SO, but it's not working for me. I also tried looking at this answer, but I'm not able to apply this to my piece of code No generic method 'OrderBy' on type 'Queryable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. MethodCallExpression orderByCallExpression =

Entity Framework NullReferenceException calling ToList?

∥☆過路亽.° 提交于 2020-01-14 09:32:10
问题 I'm very new to WPF and the EF, and I'm trying to display some data from a table in a datagrid. I've got the entity model pulled from an existing database and simple operations seem to work (getting row counts, using 'first'). I'm running against Firebird 2.5.0 using the 2.0.5 DDEX provider and 2.5.2 ADO NETProvider. When I try to get the data into the grid or simply into a list, I get a null reference exception. Possibly I just don't understand how to use the entity framework, but the

Entity Framework NullReferenceException calling ToList?

北战南征 提交于 2020-01-14 09:32:06
问题 I'm very new to WPF and the EF, and I'm trying to display some data from a table in a datagrid. I've got the entity model pulled from an existing database and simple operations seem to work (getting row counts, using 'first'). I'm running against Firebird 2.5.0 using the 2.0.5 DDEX provider and 2.5.2 ADO NETProvider. When I try to get the data into the grid or simply into a list, I get a null reference exception. Possibly I just don't understand how to use the entity framework, but the

Many to many relationship detecting changes

荒凉一梦 提交于 2020-01-14 09:23:31
问题 I am trying to understand why DbContext doesn't detect changesin many-to-many relationship. This is what I have set in model configuration: this.Configuration.ValidateOnSaveEnabled = false; this.Configuration.ProxyCreationEnabled = false; this.Configuration.LazyLoadingEnabled = false; This is the test code: var book = Context.Set<Book>().Where(b => b.Id == 1).Single(); var author = Context.Set<Author>().Where(a => a.Id == 2).Single(); book.Authors.Add(author); if I check for changes, it doesn

Many to many relationship detecting changes

做~自己de王妃 提交于 2020-01-14 09:23:29
问题 I am trying to understand why DbContext doesn't detect changesin many-to-many relationship. This is what I have set in model configuration: this.Configuration.ValidateOnSaveEnabled = false; this.Configuration.ProxyCreationEnabled = false; this.Configuration.LazyLoadingEnabled = false; This is the test code: var book = Context.Set<Book>().Where(b => b.Id == 1).Single(); var author = Context.Set<Author>().Where(a => a.Id == 2).Single(); book.Authors.Add(author); if I check for changes, it doesn