entity-framework

Is the combination of ADO.NET Entity Framework and ASP.MVC wrong by any chance?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-12 12:51:22
问题 I have one solution with three projects. DomainModel (C# Library with ADO.NET Entity Framework) DomainModelTest (Unit Testing for Business Logic) WebApp (Using DomainModel) For some reason, I cannot even bring the view if I pass any of the objects in the DomainModel, not even simple. I get the error below: Any ideas? Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly

Is the combination of ADO.NET Entity Framework and ASP.MVC wrong by any chance?

社会主义新天地 提交于 2020-01-12 12:50:29
问题 I have one solution with three projects. DomainModel (C# Library with ADO.NET Entity Framework) DomainModelTest (Unit Testing for Business Logic) WebApp (Using DomainModel) For some reason, I cannot even bring the view if I pass any of the objects in the DomainModel, not even simple. I get the error below: Any ideas? Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly

Using BindingSource to bind to Nested Properties - or, Making Entities Bindable

做~自己de王妃 提交于 2020-01-12 12:49:26
问题 Binding to a nested property is easy enough: checkBox1.DataBindings.Add(new Binding("Checked", bindingSource, "myProperty")); //Normal binding checkBox2.DataBindings.Add(new Binding("Checked", bindingSource, "myProperty.innerProperty")); //Nested property However, when myProperty.innerProperty is changed, no events are raised - the BindingSource is never notified of the change. I've read that the solution is to "make sure that when the innerProperty object raises the PropertyChanged event,

Cast a IQueryable type to interface in Linq to Entities

你说的曾经没有我的故事 提交于 2020-01-12 07:33:07
问题 I have the following method in my generic class: // This is the class declaration public abstract class BaseService<TEntity, TKey> : IBaseService<TEntity, TKey> where TEntity : class, IEntity<TKey> // The Method public IQueryable<TEntity> GetActive() { if (typeof(IActivable).IsAssignableFrom(typeof(TEntity))) { return this.repository.Get().Cast<IActivable>() .Where(q => q.Active) .Cast<TEntity>(); } else { return this.Get(); } } This is the interface: public interface IActivable { bool Active

Database default value is not inserted while create record by entity framework

南笙酒味 提交于 2020-01-12 07:31:13
问题 I have a LoginRecord table in sqlserver 2008 with the following column structure- LoginId - int, identity UserId - int LoginDateTime- Allow nulls false,default value getdate() I am inserting new record by entity framework 6 as below- db.LoginRecords.Add(new LoginRecord() { UserId = UserId }); db.SaveChanges(); But in LoginDateTime table, null value is being inserted. It supposed to be current datetime. I am using database first approach. How can overcome this issue? 回答1: Combined my two

How is the “Owning Side” of this many-to-many relationship determined?

筅森魡賤 提交于 2020-01-12 07:29:46
问题 I'm trying to get a firm grasp on the concept of Owning-side. Couldn't really get a clear picture from any question i found here. Basically I'm going through the Java EE JPA tutorial. They have the following database schema, where PLAYER and TEAM have a many-to-many relationship Also stated A player can be on many teams. A team can have many players. There is a many-to-many relationship between PLAYER and TEAM . Pretty straight forward so far. But when is gets to the coding part, they make

How to make connection strings available in a T4 template?

て烟熏妆下的殇ゞ 提交于 2020-01-12 07:05:33
问题 I've written a T4 template where I instantiate an EF context to read some data. The problem is that the context cannot see the connection string from the Web.config. How can I make the connection strings from the Web.config available to the template? More info: template is written from scratch EF edmx is located in another project the first query I make in the template tells me that it cannot find the required connection string in the project where the template resides Tried some of the

How to make connection strings available in a T4 template?

别来无恙 提交于 2020-01-12 07:04:04
问题 I've written a T4 template where I instantiate an EF context to read some data. The problem is that the context cannot see the connection string from the Web.config. How can I make the connection strings from the Web.config available to the template? More info: template is written from scratch EF edmx is located in another project the first query I make in the template tells me that it cannot find the required connection string in the project where the template resides Tried some of the

How to make connection strings available in a T4 template?

人盡茶涼 提交于 2020-01-12 07:04:02
问题 I've written a T4 template where I instantiate an EF context to read some data. The problem is that the context cannot see the connection string from the Web.config. How can I make the connection strings from the Web.config available to the template? More info: template is written from scratch EF edmx is located in another project the first query I make in the template tells me that it cannot find the required connection string in the project where the template resides Tried some of the

Get All Children to One List - Recursive C#

江枫思渺然 提交于 2020-01-12 04:30:30
问题 C# | .NET 4.5 | Entity Framework 5 I have a class in Entity Framework that looks like this: public class Location { public long ID {get;set;} public long ParentID {get;set;} public List<Location> Children {get;set;} } ID is the identifier of the location, ParentID links it to a parent, and Children contains all of the children locations of the parent location. I'm looking for some easy way, likely recursively, to get all "Location" and their children to one single List containing the Location