Is it possible to call a custom method in a lambda expression.?
//Address a : It's an Entity
public string AddressConstructor(Address a)
{
return a.City + "," + a.Province;
}
var Test = _db.MyTableTest.Select( t => new ViewModel
{
MyID = t.ID,
...
Let's say I have in my database multiple db schema for example : HumanRessources and Inventory.
In each of those schema contains multiple tables. Do you usually split your DB into multiple edmx or usually just put everything in one single edmx?
I was thinking about creating a edmx for each schema, but wondering how this will impact a u...
I am fairly new to entity framework, and i am planning to use it in my next project.
what permissions should web give to the sql server user login which entity framework uses?
since i read entity framework does DML operations do i need to provide datawriter role to login?
...
I want to load an entity and it's children conditionally (I only want to eager load the children when the child.IsActive == true). How do I perform the following?
var parent =
from p in db.tblParents.Include("tblChildren") <-- where tblChildren.IsActive == true
where p.PrimaryKey == 1
select p;
NOTE: I do not want to retu...
I've written compiled queries for my ObjectContext which I use as select methods in a ObjectDataSource. The proble is that I now want to implement sorting and paging and I'd like to it in data layer which means I need to add .OrderBy and .Take/.Skip to my compiled queries. Does this make sense? I mean won't the compiled query recompile e...
I am new to both MVC as well as Entity Framework, but I want to do my next project using those technologies. I went through the NerdDinner tutorial at http://nerddinnerbook.s3.amazonaws.com/Part1.htm. NerdDinner uses Linq to Sql and uses the Repository pattern to manage data access. NerdDinner is written so well that I wanted to use it...
I know there are a lot of threads here already on the repository pattern but somehow I feel my question is a little different. May be because yesterday was the first time I heard of the word POCO.
My question is this--usually, I have add and save methods in my business entities. Say I am writing a Q/A site, and I have the following e...
Currently I am updating the scalar properties of the candidate object like so:
public Candidate EditCandidate(Candidate candidateToEdit)
{
_entities.Candidates.Attach(new Candidate { ID = candidateToEdit.ID });
_entities.Candidates.ApplyCurrentValues(candidateToEdit);
//update candidate.contact h...
The code that gets generated by Entity Framework 4--mainly the AddTo and Create methods--should I be using those directly? I'm trying to understand the Create method. The CreateDinner method (in NerdDinner) for example is this:
public static Dinner CreateDinner(global::System.Int32 dinnerID, global::System.String title, global::System...
I have a view that I have been trying to map in either entity framework or linq to sql. However when querying the view it just crashes horribly (it is just this view).
Because the error message is completly generic I thought I would just divide and conquer, and delete half the columns on my view (in sql server), and then update the Dat...
As the title says, somehow the entity designer disappeared from my installation of Visual Studio 2010.
When trying to open an .edmx file, it only opens it in the XML editor. When i choose "Open With...", the Entity designer doesn't show up in the list.
It has worked before, and i don't know of anything i could have done to remove it from...
I have a a function that I want to return a new entity with some child entities already attached. What I dont want to do is create them in the database first. I just want to create an new instance of the entity, create some new child entities and add them to the parent entity before returning the parent entity in the function.
I started...
Hey all,
I went to the Visual Studio 2010 launch and remember seeing someone generate entites (which I am using and is awesome) from a database, but then taking it a step further and creating a web front end. The front end would allow modification/deletion of existing data and addition of new, and it was all generated.
It was ugly, of...
I need to load an object from the database, modify some of its fields and relations, and then I want to store a new value for only one field, without modifying the rest.
It would look something like this:
var thing = db.Things.First();
thing.Field1 = "asdas";
thing.Field2 = 23;
thing.OtherThings.Add(new OtherThing());
thing.FieldToUpd...
I have a property auto-generated from database in my edmx: Description. I then create a "partial class" .cs file for the entity and add a read-only property: ShortDescription.
ShortDescription's getter simply processes Description (removes line feed, carriage return, etc).
How can I raise property change notification for ShortDescript...
I have a fairly large Entity Diagram. I tried to export it to an image, unfortunately because it's so large the image comes out all pixelated.
See this link http://connect.microsoft.com/VisualStudio/feedback/details/534574/edmx-model-image-export-pixelation for the error report (made by someone else).
So I was wondering is there anothe...
I want to update my ADO.NET Entities Framework Model from the database, but I cannot find the Entity Model Browser Window. There is an example of how to update my model here, but I cannot find how to open the model browser. Could someone please tell me exactly how to open it using Visual Studio 2010?
I tried finding it through the view ...
I am working with Entity Framework on a new Project. I've been using EF since a year ago. Today i've tried to generate Entity Data Model with Visual Studio (2008 SP1 and 2010) and it is generating object context properties and entitysets but has not generated SaveChanges method. I've even tried with databases that i've used previosuly to...
I find I'm confused about lazy loading, etc.
First, are these two statements equivalent:
(1) Lazy loading:
_flaggedDates = context.FlaggedDates.Include("scheduledSchools")
.Include ("interviews").Include("partialDayAvailableBlocks")
.Include("visit").Include("events");
(2) Eager loading:
_flaggedDates = context.FlaggedDates;
In oth...