ADO.NET :: EF Saving Related Entities?
Aug 11, 2010
Having the following model Admin and AdminGroup is joined by AdminAdminGroup which has (AdminId, AdminGroupId) fields. When I add a new Admin row AdminGroups are associated with it automatically however this only works on INSERT.When I'm trying to update or associate more AdminGroup's with particualr Admin row (_repo.Update((DataLayer.Admin)row);) only Admin gets updated and no groups are ever modified.What is the correct way of updated "related" entities? so that AdminGroup also get's updated.
View 6 Replies
Similar Messages:
Mar 5, 2010
Inserting Related Entities?
View 14 Replies
Aug 3, 2010
I'm working with asp.net 3.5 WebForms and LINQ to Entities.
I created the database with their relationships, but when I go to import the data with LinqToEntities, some reports and have not seen any reports 1 to 1.
I can create them after the reports have imported the tables LinqToEntities?
View 1 Replies
Jun 12, 2010
I'm using ASP.NET MVC 2 and am struggling with saving child entities. I have an existing Invoice entity (which I create on a separate form) and then I have a LogHours view that I'd like to use to save InvoiceLog's, which are child entities of Invoice. Here's the view:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TothSolutions.Data.Invoice>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Log Hours
</asp:Content>.......
In the SaveHours action, it properly sets the values of the InvoiceLog entities after I call TryUpdateModel but when it does SaveChanges it doesn't update the database with the new values. Also, if you manually update the values of the InvoiceLog entries in the database and then go to this page it doesn't populate the textboxes so it's clearly not binding correctly.
View 1 Replies
Nov 16, 2010
I have a datamodel with a couple of tables. One of my tables have about 40 fields (I know that is a lot, but we have to keep the structure in place as we are upgrading a classic ASP project to MVC). Some of my Actions only updates 1 or 2 fields in my table.
Is there a way to create Entities, for instance, that only contains the contact details of the client table, and not any other details, and then another entity that contains only the address details. I don't want to submit the entire row when I only update telephone details, or the client's picture.
View 1 Replies
Sep 28, 2010
We are starting a new web based product in which we are planning to expose our business logic through WCF services. We will be using ASP.NET 4.0, C#, EF 4.0. In future we want to build iphone applications and WPF applications based on the services. I have been reading a lot about using POCO vs Self Tracking Entities (STE) and from my understand the STEs do not work well with the web scenario.
View 3 Replies
Sep 25, 2010
How to use Stored Procedures with Linq to Entities? I prefer an example with input and output The videos on asp.net only show how to do this with Linq to SQL.
View 5 Replies
May 13, 2010
I have a simple join:
SELECT * FROM MessageAlerts AS A LEFT OUTER JOIN Contacts AS C ON A.ContactId = C.Id LEFT OUTER JOIN
Users AS U ON A.UserId = U.Id INNER JOIN Businesses AS B ON B.Id = C.BusinessId OR B.UserId = U.Id
how to do this : ON B.Id = C.BusinessId OR B.UserId = U.Id with linq in entity framework.
View 2 Replies
Mar 4, 2010
I am working on a class library using C#. I have designed 3 main classes to model our data. They are designed such that class A contains a list of class B instances, and class B contains a reference to a class C instance, ie:
[code]....
I feel like the class design works well for modeling the data and our business rules, but it does create a few limitations like the above situation. I liked the separation of the PolicyTerm and Billing for the ability to allow that code to be modified and tested independently. Also, I feel like it keeps each section smaller and simpler.
View 5 Replies
Nov 21, 2010
I want to have two combo boxes: One for categories and one for subcategories. As a category is selected in one combo box, all the related subcategories are displayed in the other combo box. EF 4.0 should be perfect for this. But the subcategory collections are always empty!
[Code]....
I can see that Lazy loading is set to true. I tried setting it to false and adding Include("Subcategories") but the subcategories collection is always empty.
I even tried using the SQL Server Profiler. Although I couldn't explain the timing, I could in some cases see the queries to return the subcategories. I even executed the query and it returned the expected results.
I'm really getting frustrated by EF. Although I'm fairly new to SQL Server, I could've had what I'm working on done hours ago. Instead, it's like a black box with no way for me to troubleshoot or determine what the heck is going wrong.
View 8 Replies
Jan 18, 2011
I have 2 tables:
User(Id PK, TitleId FK, Name, Active)
Title(Id PK, Text)
Title is a lookup table of titles (Mr, Miss,...) and its got a relationship with table User by TitleId.
Now I'm trying to display the data in a web page using .net and Entity Framework. I'm using a ListView control and a query as a source. it all displays fine except for the Title.
Here is my code:
MyEntities _entities = new MyEntities (); User user = new User(_entities); IQueryable u = (from x in _entities.Users where x.Active == true select x); ListView1.DataSource = u; ListView1.DataBind();
and the code in the front end:
<asp:ListView ID="ListView1" runat="server" EnableModelValidation="True" DataKeyNames="Id"><ItemTemplate> <tr> <td> <%# Eval("Id") %> </td> <td> <%# Eval("Title.Text") %> </td> <td> <%# Eval("Name") %> </td> </tr></ItemTemplate><LayoutTemplate> <table ID="itemPlaceholderContainer" runat="server"> <tr runat="server"> <th id="Th2" runat="server"> Id</th> <th id="Th1" runat="server"> Title</th> <th id="Th3" runat="server"> Name</th> <th runat="server"> </tr> <tr runat="server" ID="itemPlaceholder"> </tr> </table></LayoutTemplate>
How do I manage to get the Title Text associated with a User to display on the ListView?
View 4 Replies
Jun 10, 2010
What i want to do is have a grid i can add rows and columns and cells. each cell i want to have an image button in. I want to do this in a windows form. Is this posible? I was looking into the gridview/datagridview but that wasn't what i wanted.
View 1 Replies
Jan 27, 2010
WHY are all the examples on this site linq to SQL? Did ms not themselves announce dropping support for l2SQL over a year ago? i really don't get it. Examples are great.. but really not helping me since i've gone ahead and listened to MS. And can someone at MS clarify what the position is for linq 2 SQL.. Is it supported? Recommended? What the hell.
View 7 Replies
Mar 9, 2011
I use Linq To Entities to get 2 objects m1 & m2. And I don't understand why 2 different objects reference the SAME Template table.
I suspect that the reason due to the connection between MConfigOnPage1, MConfigOnPage2 with MConfiguration. Maybe it should be splitted somehow?
Here I attached my ERD and the code.
[Code]....
View 2 Replies
Feb 19, 2011
I make ASP.NET MVC3 application for spa and I've encoutered problem with M:N relationship. I've got this model Each Insurance Company has different pricing for each patient medical indication, so sample data looks like this:
IC
Indication
Patient
IC1
Indication1
Patient1
Patient2
Indication2
Patient3
[Code]....
And I don't know how to make Edit with possibility of changing not only Indication but IC to.
View 1 Replies
Mar 28, 2011
i am having a little problem in mapping all the entities in contained in the namespace "nhibernateTest.Domain" . it basically contains all the Map Classes like , StudentMap, DepartmentMap etc. .. now in case of normal nhibernate what we used to do is :
[Code]....
now what it used to do is . look for all the "*.hbm.xml" files in my namespace and automatically map them...
how to do the same for fluent nHibernate ? so that it looks for all map classes in folder
"nhibernateTest.Domain" ...resolve the namespace "nhibernateTest.Domain"... and automatically map them so that i dont have to create the session separately for diffrent Map classes ?
View 1 Replies
Apr 20, 2010
I have the following admx:
I have to add the (AccData, CntactData, PhnNumber, FnclDetail)entities to the database in one shot
What's the best practices to do the add operation for the above entities??
View 2 Replies
Dec 23, 2010
I have I method where I insert muliple records to a SQL Server 2008 database. The table in which the records are inserted has a primary key integer column with auto increment. The problem is that I have another column called GroupId where I want an integer representing the current insert to be set, i.e. for each time the method gets called a new group id should be generated the group id column of the records to be inserted should be set to this value. What's the best way to generate this group id? I guess I could do a SELECT MAX(GroupId) + 1 FROM Table to generate an id before I make the inserts but this won't be a good solution when it comes to concurrency.
View 13 Replies
Nov 10, 2010
I am trying to learn LINQ to entities, and am working out how to best structure my BLL layer. I have generated the entity model and have created a generic repository in my DAL that returns results as IList<T>. I initially created the BLL to also return
results as IList<T>:
public IList<DAL.Customer> SelectAll()
{ [code]...
Now I am working on the aspx page, and I can create an ObjectDataSource and configure it to use my BLL, but since I am returning IList, I can't sort since I am not using a DataView. I have seen some articles on the web for converting IList to DataView, but that seems like a lot of overhead for every query.My goal is to keep a clean separation between layers without making things overly complicated. I would like to know how others have done this, or maybe a link to a good tutorial that shows how to structure all three layers.
View 8 Replies
Sep 3, 2010
im looking for ecommerce development video tutorial. I already watched related video tutorials on ASP.net website.
View 2 Replies
Jan 3, 2011
I have a table articles where i keep all the records of the articles wriiten by people online. Now i need to retrieve related articles based on the title i guess. I tried doing that using my stored procedures with the LIKE operator, but i guess that doesn't work because it does not take the whole string of the title and match with the ones in the database.
View 2 Replies
Nov 9, 2010
Here's my DB structure:
I have three tables.
User, Details, Optional
User has fields: ID, FirstName, LastName
Details has fields: ID, MyDetails1, MyDetails2, User_ID
Optional has fields: ID, MyOptions1, MyOptions2, User_ID
There is a 1 to many relationship with User & Detail (User ID & Detail User_ID)
There is a 1 to many relationship with User & Optional (User ID & Optional User_ID)
With that said, one user can have many details and/or many optionals
Now I'm trying to build a linq query that will say:
"where user id = x, select FirstName, LastName, all MyDetails1 from every record where User_ID == x, all MyOptions1 from every record where User_ID == x"
After the merge I should have one string that lists the distict user & all of their many fields:
FirstName + LastName + (MyDetails1 + MyDetails1 + MyDetails1..etc) + (MyOptions1 + MyOptions1)
Anyone try this before?
I tried this with JOIN but this doesn't do the trick for what I'm looking for.
So if I had 3 MyDetails records associated with ID == 2, I would get three results like:
John Doe MyDetails_X
John Doe MyDetails_Y
John Doe MyDetails_Z
View 1 Replies
May 20, 2010
What's the best way in ASP.NET MVC to get a few questions related to the current question (like on stackoverflow) without using tags?
View 1 Replies
May 17, 2010
I'm tying to create a paragraph, like a news paragraph with a related links at the end of it, as we can see in many news websites.
View 8 Replies
May 29, 2010
I have and Article object that I update in my controller.... the object is passed into the controller and then I just call UpdateModel(inArticle) and it was all good. I now expanded my article to belong to a category and want to do that update there as well. I am not sure if it was the right thing to do but just as a start i hard-coded an update to the ArticleCategory table, just after I do the UpdateModel. This works but I am not sure how to code this update?
I am using the repository patter and i somehow feel that I should be passing an Article and an ArticleCategory object from the view to the controller? While I was writing this I thought that I could just extend my article object to include the categoryID but what if I really wanted to pass two un-related objects from the view to the controller? The UpdateModel persistes the database objects as by VoodooMagic, how would it work if I wanted to update 2 un-related objects?
View 3 Replies