"Order by Col1, Col2" using entity framework
Hello I need to order by 2 columns using the entity framework. How is that done? return _repository.GetSomething().OrderBy(x => x.Col1 .. Col2)? i.e SELECT * FROM Foo ORDER BY Col1, Col2 /M ...
Hello I need to order by 2 columns using the entity framework. How is that done? return _repository.GetSomething().OrderBy(x => x.Col1 .. Col2)? i.e SELECT * FROM Foo ORDER BY Col1, Col2 /M ...
I currently have a .NET solution I'm developing that involves several sub-projects, including an ASP.NET MVC project. My model has been separated into a separate assembly because I need to use it from the various other projects in the solution. My model consists of an ADO.NET Entity Framework entity model. I have decided to go with a si...
Let's say I have a method: bool myMethod(int a) { //return a bool } So let's say I the following // assume a has prop1 and prop2 both ints var mySelection = from a in myContainer where a=somecondition select new { a.prop1, myMethod(a.prop2) ...
We use LINQ to Entities to write entries into an Audit database (SQL Server 2008). Since this is a dedicated Audit database, we only insert rows - we never read any rows, update or delete them from the auditing application. The auditing application should use the principle of Least Privilege, so we don't wish to grant it more permission...
Is there any backward compatibility in the entity framework between SQL Server 2008 and 2005? It seems the framework forces you to use the same provider for all the .edmx files in a solution. If you use the 2008 provider, data types like DateTime2 and functions like SysDateTime that are emitted by the framework to the underlying SQL q...
Hello How can I change this method so it also returns Max(t.StartTime) and Min(t.StartTime) with only using it in one line as below? public IQueryable<Timetable> GetTimetables() { return from t in _entities.Timetables select t; } /M ...
Hello, "System object" is a table & its key is auto increament "Security entity" view that get id get Id from "System object" "User" is a table has a many-to-many relation with "System Object" "Role" is a view In the model: Security Entity ..... inharits from System object user ..... inharits from Security entity...
I am porting an application running on LINQ-to-SQL to Entity Framework, and am having trouble finding an equivalent to ExecuteCommand: db.ExecuteCommand("INSERT Infos (Title) VALUES ('this is an added title')"); I found this site which tells me that it is possible to implement ExecuteCommand as an extension method on your ObjectContex...
I'm migrating an application from LINQ-to-SQL to Entity Framework and have changed the line: using (var db = new MainDataContext(SystemHelpers.GetDatabaseConnectionString())) to using (var db = new MainDataEntities(SystemHelpers.GetDatabaseConnectionString())) where SystemHelpers.GetDatabaseConnectionString()) is a file path to an...
I have 3 tables of data and a fourth table that maps between them i.e. 3 id's with all three columns as primary key. What I really want is object A to contain a List where B is an object that contains List. I'd settle for a 2 dimentional array of B and C in A. Is there a way to do this? Am I going about this all wrong? ...
I find myself repeating bits of code like this over and over while using ADO.NET Entity Framework. VB: ' Load the thing if not already loaded. ' If Not Something.Thing.IsLoaded Then Something.Thing.Load() End If C#: // Load the thing if not already loaded. if (!Something.Thing.IsLoaded) { Something.Thing.Load(); } Is this ...
We have a class called Task: public partial class Task : EntityObject { public EntityCollection<TaskUser> TaskUsers { get {...} set{...} } } It has navigation property called TaskUsers, which contains users attached to this taks: public partial class TaskUser : EntityObject { public User User { get {...} set { } } } Every...
I must have changed something somewhere, but damned if I can figure out what it is. I have a DAL that handles all my data access (as is a DAL's wont) to my SQL Server DB. This includes the Entity Model, the repository classes and the connection string in the App.Config file. Somewhere along the piece, I must have changed something and...
Hi, i can't seem to find the answer to this.... i have some data coming from other tiers and it represents a EF object. When it's new, i do this: context.AddToCustomer(mynewobject); context.SaveChanges(); but now my data forms an existing object, so i want the context to know i want to update the data and not inserting it. i've seen...
Is it possible to create associates b/t 2 non-key fields in the Entity Framework? Example: Take the 2 tables in a legacy application (i.e. keys/structure cannot change) Order - OrderId : int : PK - OrderNo : varchar OrderDetails - DetailRecordId : int : PK - OrderNo : varchar In the Entity Framework, I want to create an associatio...
I am getting the following error when trying to attach an object that is already attached to a given context via context.AttachTo(...): An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key. Is there a way of achieving something along the lines o...
Hi all, While developing & learning with Entity Framework, I'm having a curious problem with inserts when I run the tests for one entity in my model. In concrete, the problem is when running some tests together. I'll explain myself: I have one entity in my model called "DtoCategoria", with 2 members: id:Int32 and name:string, mapped to...
Hi, I have a C#.NET Silverlight 3.0 client running RIA Services with an EF model. I'm trying to set up an advanced search system on the client such that the user can say, I want field (property) "Foo1" to have value "Bar1," etc.. . I'd like to use a flexible, dynamic approach similar to this one. The problem is I can't pass IQueryable ...
Why, when I go through my unit tests in VS2008 - either using run or debug - does VS insist on rebuilding all the dependencies of the test project i.e. the projects that I'm testing in the unit tests? Sometimes they haven't changed - I've just amended some of the unit tests. Or perhaps I've modified one of the assemblies - yet it insist...
Is it possible to create associates b/t 2 non-key fields in the Entity Framework? Example: Take the 2 tables in a legacy application (i.e. keys/structure cannot change) Order - OrderId : int : PK - OrderNo : varchar OrderDetails - DetailRecordId : int : PK - OrderNo : varchar In the Entity Framework, I want to create an association ...