entity-framework-4

Executing SQL Stored Procedure with Output Parameter from Entity Framework

眉间皱痕 提交于 2019-12-17 19:20:46
问题 Using EF, I'm trying to execute a stored procedure that returns a single string value, i.e. the status of an SQL Agent Job. The stored procedure is declared as CREATE PROCEDURE [dbo].[up_GetJobStatus](@JobStatus NVARCHAR(30) OUTPUT) AS -- some code omitted for brevity SELECT @JobStatus = ( SELECT CASE job_state WHEN 1 THEN 'Executing' WHEN 2 THEN 'Waiting for thread' WHEN 3 THEN 'Between retries' WHEN 4 THEN 'Idle' WHEN 5 THEN 'Suspended' WHEN 6 THEN '<unknown>' WHEN 7 THEN 'Performing

“Update Model from Database” does not see a type change

倾然丶 夕夏残阳落幕 提交于 2019-12-17 19:18:40
问题 I have several columns that I changed from Int to BigInt. I opened up my EF model and did an 'Update Model from Database' and expected to see those columns now be Int64s. But they are still Int32s. (I ran it several times just to be sure.) I double checked my database and the columns are definitely BigInts. So... does 'Update Model from Database' not work for a change of data type? Does it need to be manually applied? 回答1: Unfortunately, you'll need to delete the items from your model and

EF4 and undesired loading of related collection with AddObject

China☆狼群 提交于 2019-12-17 18:58:51
问题 I have an odd case where adding a record is causing unwanted loading of a related collection. For example, I have Requests and Sessions. A Session can contain many Requests. I already have loaded the session, and just want to add a new request. However, when I set call AddObject on the ObjectSet of the Request repository, SQL Profiler shows a select query getting executed on all related requests on that session. Here is the problem code: this._request = new Request { Action = (string

EF4 cross database relationships

左心房为你撑大大i 提交于 2019-12-17 18:58:35
问题 I was wondering if EF4 support cross-databse relationships? For instance: db1 Author Id Name db2 Posts Id Content db1.Author.Id What ideally I need to do to get this relation in my ef4 model? Do you guys have any idea? Thanks 回答1: I've found this entry in Microsoft Connect that answers the question about the support given at this moment by EF (actually it is not supported yet). Also found a thread in Social MSDN about this concern. Other links on Stack Overflow: ADO.Net Entity Framework

Entity Framework 4 Code First - Prevent DB Drop/Create

倾然丶 夕夏残阳落幕 提交于 2019-12-17 18:39:57
问题 I've written an ASP.Net MVC 3 application using the Code First paradigm whereby when I make a change to the model the Entity Framework automatically attempts to re-create the underlying SQL Server Database via DROP and CREATE statements. The problem is the application is hosted on a 3rd party remote server which limits the number of databases I can have and does not seem to allow me to programmatically execute "CREATE DATABASE..." statements as I gather from this error message: CREATE

The version of SQL Server in use does not support datatype datetime2?

一曲冷凌霜 提交于 2019-12-17 18:26:10
问题 An error occurred while executing the command definition. See the inner exception for details. bbbbInnerException:aaaa System.ArgumentException: The version of SQL Server in use does not support datatype 'datetime2'. at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior

How do I concatenate strings in Entity Framework Query?

…衆ロ難τιáo~ 提交于 2019-12-17 18:23:22
问题 How do I concatenate strings in Entity Framework 4 I have a data from a column and I want to save as a string a comma separated string like "value1, value2, value3" Is there a method or an operator do do this in EF4? Example: lets say that I have two columns Fruit and Farms with the following values: Apples Bananas Strawberries If I do like this var dataSource = this.context .Farms .Select(f => new { f.Id, Fruits = string.Join(", ", f.Fruits) }); Sure I will get this error LINQ to Entities

Readonly properties in EF 4.1

泄露秘密 提交于 2019-12-17 17:46:15
问题 I've faced with situation when I need to have EF readonly property in case of 'optimistic update'(you do not load current state of your domain object from database to check what properties are really changed. You just set your object as Modified and update it to database. You avoid redundant select and merge operations in this case). You can't write something like this : DataContext.Entry(entity).Property(propertyName).IsModified = false; , because setting of 'false' value is not supported

bottleneck using entity framework inheritance

你。 提交于 2019-12-17 16:49:22
问题 so first my entities the problem i want to have a page with all the story titles and their types there are three stories LongStory , CoOpStory , GenericStory the generic story is associated with StoryType for the type of the generic story i have two problems first when i want to check if the story is LongStory or CoOpStory i have to get all the entity and check the entity type if it is LongStory then do something , i don't know how to retrieve some data [only the title] and check the type my

Entity Framework Optimistic Concurrency Exception not occuring

青春壹個敷衍的年華 提交于 2019-12-17 16:37:30
问题 We have an ASP.Net MVC application that uses EF4 as its data access layer and we're seeing unexpected behaviour with regards to OptimisitcConcurrencyExceptions not being thrown when we think they should be. We have simplified the problem down to the following code... using System.Linq; using Project.Model; namespace OptimisticConcurrency { class Program { static void Main() { Contact firstContact = null; using (var firstEntities = new ProjectEntities()) { firstContact = (from c in