entity-framework-4

Entity Framework Where method parameters

≡放荡痞女 提交于 2020-02-07 06:46:32
问题 The following EF statement does not compile as it is expecting 2 additional parameters, an int and a bool. I can't figure out how to supply them or what they are used for. Dim L2 = Db.SecurityLogs.Where(Function(x) x.OrderId = OrderId) The compile error is; Error 27 Overload resolution failed because no accessible 'Where' can be called with these arguments: 'Public Function Where(predicate As String, ParamArray parameters() As System.Data.Objects.ObjectParameter) As System.Data.Objects

RIA Services: Entity Framework Reference Entities

允我心安 提交于 2020-02-06 04:28:06
问题 I'm attempting to use RIA services with a Entity Framework back end. The Model was auto generated by the designer. (VS 2010, .NET 4.0, EF 4.0, SilverLight 4.0) The issue that I'm running into is that Reference Properties are being loaded as expected at the Service Layer, but when that information is passed over to the SilverLight App the Reference Entity becomes NULL. I've used two approaches to populating the Reference Entity: public Employee GetEmployeeByID(int employeeID) { var result =

When to use ApplyOriginalValues in Entity Framework 4?

房东的猫 提交于 2020-02-03 04:27:13
问题 I have used ApplyCurrentValues. But don't really understand ApplyOriginalValues. How is it different from ApplyCurrentValues? When should I use it? I have read the documentation. But still confused. 回答1: Each entity loaded from the database keeps two sets of values - original (those loaded form DB) and current (those you are modifying). These two sets are hold in ObjectStateEntry . Usually each save is followed by accepting changes which takes current values and writes them to original values

Does this implementation of the Entity Framework leaks memory?

霸气de小男生 提交于 2020-01-25 12:23:34
问题 I just can't make out if the entity context is disposed in the usage flow when used in a using statement in a web application or a console application. Thanks! using System; using System.Web; namespace Foo.Model { public partial class FooEntities : ObjectContext { private const string CurrentContextKey = "FooEntities.Current"; [ThreadStatic] private static FooEntities _currentOnThreadStatic; private FooEntities _previousContext; /// <summary> /// Gets the current <see cref="FooEntities"/>

Entity Framework 4 exception not being thrown / caught

左心房为你撑大大i 提交于 2020-01-25 06:32:35
问题 I am connecting to a MySQL database from Visual Studio 2010 using Net/Connector. This is the entity framework 4 linq query: int timeThreshold = 5; DateTime cutoffTime = DateTime.Now.AddMinutes(-timeThreshold); try { using (var context = new myEntities()) { var unprocessedMessages = from m in context.messages where m.createdDate < cutoffTime select m; } } catch (Exception e) { string exceptionString = e.InnerException.ToString(); } The Results view in the expanded unprocessedMessages displays

Entity Framework 4 exception not being thrown / caught

妖精的绣舞 提交于 2020-01-25 06:32:12
问题 I am connecting to a MySQL database from Visual Studio 2010 using Net/Connector. This is the entity framework 4 linq query: int timeThreshold = 5; DateTime cutoffTime = DateTime.Now.AddMinutes(-timeThreshold); try { using (var context = new myEntities()) { var unprocessedMessages = from m in context.messages where m.createdDate < cutoffTime select m; } } catch (Exception e) { string exceptionString = e.InnerException.ToString(); } The Results view in the expanded unprocessedMessages displays

Custom property: gotta be something obvious I'm doing wrong

萝らか妹 提交于 2020-01-24 18:33:23
问题 I have been adding partial classes of my different entities to add various useful methods without issue. Attempting to add properties appears to be straightforward based on examples that I've seen, but mine are failing miserably. Updated example: public List<Friend> FriendsInGoodStanding { get { using (var context = new GarbageEntities()) { var a = context.Friends.Include("aspnet_User1").Where(f => f.UserID == this.UserId && f.Blocked == false).ToList(); var b = context.Friends.Include(

CompiledQuery with List.Contains (where…in list) functionality?

狂风中的少年 提交于 2020-01-24 14:29:48
问题 I'm attempting to write a CompiledQuery using Linq-to-Entities that will replace a stored procedure that takes two array (in this case, comma-delimited TEXT) parameters. Essentially, the SQL is be something like this: *Stored Proc definition* @ArrayParm1 TEXT, @ArrayParm2 TEXT -- etc. SELECT [fieldList] FROM someTable WHERE someTable.Field1 IN (SELECT * FROM dbo.fncCSVToTable(@ArrayParm1)) AND someTable.Field2 IN (SELECT * FROM dbo.fncCSVToTable(@ArrayParm2)) dbo.fncCSVToTable creates a

Storing graph with EF Code First

痴心易碎 提交于 2020-01-23 23:34:49
问题 I'm trying to save a graph into a database as described here with EF Code First. I defined property with collection of adjacent nodes: public class Node { public int NodeId { get; set; } public string NodeName { get; set; } public ICollection<Node> Nodes { get; set; } } but EF generated only one table for this model: dbo.Nodes NodeId (PK, int, not null) NodeName (nvarchar(max), null) Node_NodeId (FK, int, null) How to force EF to generate many-to-many relationship? Are there any other ways to

Storing graph with EF Code First

…衆ロ難τιáo~ 提交于 2020-01-23 23:33:26
问题 I'm trying to save a graph into a database as described here with EF Code First. I defined property with collection of adjacent nodes: public class Node { public int NodeId { get; set; } public string NodeName { get; set; } public ICollection<Node> Nodes { get; set; } } but EF generated only one table for this model: dbo.Nodes NodeId (PK, int, not null) NodeName (nvarchar(max), null) Node_NodeId (FK, int, null) How to force EF to generate many-to-many relationship? Are there any other ways to