savechanges

Entity Framework Core - How to handle Related Entity Mapping and Saving

天大地大妈咪最大 提交于 2019-12-11 17:24:18
问题 I have two related entity which is one-to-many relationship like below: class parent{ public string parentName{get;set;} public virtual ICollection<child> childs { get; set; } } class child{ public string childName{get;set;} public parent parent{get;set;} ["ForeignKey"] public int parentId {get; set;} } /// View Model class VMParent{ public string parentName{get;set;} /// a string array contains child name public string[] childlist { get; set; } } Suppose my parent currently contains 2 child

How to save dynamically changed HTML?

狂风中的少年 提交于 2019-12-11 10:27:33
问题 I have around 8 div items arranged in UL LI list. Each has unique ID, and specific content.These items are sortable, I am using jquery UI for this. Once user drag and drop component position of list item changes. But after refreshing the page I am getting same HTML page. I want to retain new positions of items at server. What is the effective way to do this? I can create clone of HTML and retain it during the session but i want changes to be saved at server. The change of position of the

Entity framework doesn't save data entries in database

早过忘川 提交于 2019-12-10 14:26:01
问题 At first I should mention that this problem only occurs in windows forms applications and the same program in web mode for example with MVC3 works perfect. Some days ago I wrote a very simple windows form program using Visual studio 2010 ultimate with a SQL Express database. I added the database by choosing Add > New item > Service-Based database and an entity data model based on this database in same way. I used Entity framework for adding some new records to tables. I had done such thing

Entity Framework new transaction is not allowed because there are other threads running in the session, multi thread save

别等时光非礼了梦想. 提交于 2019-12-09 09:44:53
问题 I'm tryng to save on a DB the log of a multi thread processo but I'm getting the following error: new transaction is not allowed because there are other threads running in the session. in each tread I have this function: internal bool WriteTrace(IResult result, string message, byte type) { SPC_SENDING_TRACE trace = new SPC_SENDING_TRACE( message, Parent.currentLine.CD_LINE, type, Parent.currentUser.FULLNAME, Parent.guid); Context.SPC_SENDING_TRACE.AddObject(trace); if (Context.SaveChanges

android onSaveInstanceState usage

孤者浪人 提交于 2019-12-08 14:00:26
问题 Please guide in the following class what I should save in. Please remember I am using only one string which is I am retriving from getextra method and there is nothing which I think I should store in the following overridden method. protected void onSaveInstanceState(Bundle outState) { // TODO Auto-generated method stub super.onSaveInstanceState(outState); } Can you guide me what to store in onsave instance method and what not to? package com.wozzon.activity; import java.util.ArrayList;

Entity Framework - Initial Save is slow

随声附和 提交于 2019-12-06 13:09:05
We are implementing a system using EF4 and WPF. We are noticing an issue with the initial saving of data: when the initial SaveChanges is run there is a 4 to 6 second delay when context.SaveChanges() command is run. Every subsequent SaveChanges is very fast with no noticable delay. This is not a major issue - but an annoyance none-the-less. Has anyone out there experienced this issue and know a way around it? Thanks Problem solved: the answer was to pre-generate the model's views. The reason for this and method to implement the solution is found here: http://msdn.microsoft.com/en-us/library

Entity Framework won't SaveChanges on new entity with two-level relationship

半腔热情 提交于 2019-12-05 19:37:42
I'm building an ASP.NET MVC site using the ADO.NET Entity Framework. I have an entity model that includes these entities, associated by foreign keys: Report(ID, Date, Heading, Report_Type_ID, etc.) SubReport(ID, ReportText, etc.) - one-to-one relationship with Report. ReportSource(ID, Name, Description) - one-to-many relationship with Sub_Report. ReportSourceType(ID, Name, Description) - one-to-many relationship with ReportSource. Contact (ID, Name, Address, etc.) - one-to-one relationship with Report_Source. There is a Create.aspx page for each type of SubReport. The post event method returns

How to revert/recover .m file to a previous version? (autosaved blank by mistake and xcode crashed - no Source Control, no Time Machine)

坚强是说给别人听的谎言 提交于 2019-12-04 08:50:02
I've tried to search for the answer but I cannot precisely define the terms without falling under wrong threads all the time. What happened: Accidentally I've selected all the code inside a file.m and deleted it all. It became a full blank document . When I pressed Ctrl+Z to UNDO it, the xcode crashed . The problem: When I reopened the xcode (after the crash) , the file was still all blank ( It was autosaved seconds before the crash as a blank document ) - losing all my code . I could not use UNDO to rescue me on this because it autosaved and crash . What do I need: Is there a way to recover

Can't SaveChanges with Entity Framework in ASP.Net MVC 3 project

筅森魡賤 提交于 2019-12-04 07:51:36
Studying asp.net mvc 3 + EF code-first. I am new to both. My example is trivial, but I still can't make it work. Missing something simple and obvious... I've got a class: public class Product { [HiddenInput(DisplayValue = false)] public int ProductID { get; set; } [Required(ErrorMessage = "Please enter a product name")] public string Name { get; set; } [Required(ErrorMessage = "Please enter a description")] [DataType(DataType.MultilineText)] public string Description { get; set; } [Required] [Range(0.01, double.MaxValue, ErrorMessage = "Please enter a positive price")] public decimal Price {

Entity Framework new transaction is not allowed because there are other threads running in the session, multi thread save

天大地大妈咪最大 提交于 2019-12-03 11:35:27
I'm tryng to save on a DB the log of a multi thread processo but I'm getting the following error: new transaction is not allowed because there are other threads running in the session. in each tread I have this function: internal bool WriteTrace(IResult result, string message, byte type) { SPC_SENDING_TRACE trace = new SPC_SENDING_TRACE( message, Parent.currentLine.CD_LINE, type, Parent.currentUser.FULLNAME, Parent.guid); Context.SPC_SENDING_TRACE.AddObject(trace); if (Context.SaveChanges(result) == false) return false; return true; } the Context is different for each thread, but the