entity-framework

Linq 2 Sybase ASE database? What are the options?

I have a need to query an existing Sybase ASE database and would like to use Linq syntax for my data retrival. I don't need write access, nor do I need the full set of Linq operators, just Select(), SelectMany(), Where(), and GroupJoin() What are options are available? In particular, I'm wondering about nHibernate and building a ne...

How do I do a "like" wildcard comparison in Entity Framework in .NET 4.0?

I'm using the Visual Studio 2010 RC for .NET 4.0 and I'm trying to figure out how to do a wildcard comparison with Entity Framework. I'd like to have the following query for EF where I find all the names that start with 'J' select * from Users where FirstName like 'J%' ...

Linq to entities - How to define left join for grouping?

We have two tables - Tasks and TasksUsers (users assigned to task). Task has EntityCollection called TaskUsers. This query returns number of tasks per username: model.TaskCountByAssignee = ( from t in TaskRepository.List() from tu in t.TaskUsers group tu by tu into tug sel...

Entity framework and Exists clause

I'm a rookies of EF so, sorry for my perhaps foolish question. I've 2 entities without any relationship (VS does not load the join and I can't manually add it because the primary key of the child uses a derivated key of its parent). Example Entity master Products keys GKey_K, Product_K fields ..... Entity detail GenericInformation ...

Entity framework and associations on TPC base entites.

In my model I have a number of entities that all reference the same table. Is there a way to move this association to a base class using "Table per Concrete class" inheritance? (If so, how?) ...

Why would an Entity Framework model generator not create code for a table when I selected it?

I have Visual Studio 2008: I can create Entity Framework models on existing tables in a SQL Server 2005 database. I can create Entity Framework models on tables I create in a local SQL Server 2008 database files. However, when I add a new table to the SQL Server 2005 database, then try to create an Entity Framework model on it, it le...

Entity Framework SaveChanges error details

When saving changes with SaveChanges on a data context is there a way to determine which Entity causes an error? For example, sometimes I'll forget to assign a date to a non-nullable date field and get "Invalid Date Range" error, but I get no information about which entity or which field it's caused by (I can usually track it down by pa...

Error Using ADO.NET Entity Framework

I want to convert a list to EntityCollection. List<T> x = methodcall(); EntityCOllection<T> y = new EntityCollection<T>(); foreach(T t in x) y.Add(t); I get this error. The object could not be added to the EntityCollection or EntityReference. An object that is attached to an ObjectContext cannot be added to an EntityCol...

Why doesn't my Entity Framework app work on production server?

I get following error when deploying on test server with II6 and Framework 3.5 SP1 installed. The located assembly's manifest definition does not match the assembly reference My development machine is a 64bit pc with Visual Studio 2008. Any suggestions? ...

"Current" object of an asp:FormView bound to an EntityDataSource

I have a FormView with paging enabled. The FormView is bound to an EntityDataSource ... <asp:EntityDataSource ID="MyEntityDataSource" runat="server" ConnectionString="name=MyEntitiesContext" DefaultContainerName="MyEntitiesContext" EntitySetName="Order" // ... more stuff to define a query </asp:EntityDataSource> ...

Databinding exception with entity navigation property

I have two Entity classes: Order and OrderItem. Order contains a navigation property OrderItemSet of type System.Data.Objects.DataClasses.EntityCollection<OrderItem> On an aspx page is a FormView bound to this EntityDataSource: <asp:EntityDataSource ID="EntityDataSourceOrder" runat="server" ConnectionString="name=EntitiesContext...

Getting actionlink parameter out of route path

I'm trying to add a webform that allows the user to add a database entry with a specific foreign key. I'm creating the link like this <%= Html.ActionLink("Edit", "EditSub", new { id = id }) %> and the resulting URL is http://localhost:3015/TumourGroup/CreateSub/2 (where 2 is the id I passed to the actionlink earlier). The question is...

How to insert a new ListItem Record into Entity table using ASP.NET

Hi I want to inserd new record into my entity Table. While binding the records to Dropdownlist, we add one new ListItem like "- Select One -". If it is using ADO.NET Datasets, it is much simpler as below. But now i am using Entity Model. Ex using ADO.NET: ListItemCollection var_NewLists = new ListItemCollection(); ListItem ...

Entity Framework Object Context in ASP.NET Session object?

Hi there, We have a multi-layered Asp.NET Web Forms application. The data layer has a class called DataAccess which impements IDisposable and has an instance of our Entity Framework Object Context as a private field. The class has a number of public methods returning various collections of Entities and will dispose its Object Context wh...

How to leverage concurrency checking with EF 4.0 POCO Self Tracking Entities in a N-Tier scenario?

I'm using VS1010RC with the POCO self tracking T4 templates. In my WCF update service method I am using something similar to the following: using (var context = new MyContext()) { context.MyObjects.ApplyChanges(myObject); context.SaveChanges(); } This works fine until I set ConcurrencyMode=Fixed on the entity and then I get an ex...

Entity Framework - Merging 2 physical tables into one "virtual" table problems...

I have been reading up on porting ASP.NET Membership Provider into .NET 3.5 using LINQ & Entities. However, the DB model that every single sample shows is the newer model while I've inherited a rather old model. Differences: The User Table is split into a pair of User & Membership Tables. All of the tables in the DB are prepended...

Sharing a SQLExpress database between EF and SqlRoleProvider

I have a database in SQLExpress 2008 that I am accessing via an EF4 connection. It also contains the ASP.Net role provider tables for the website. In the web.config there are two separate connection strings pointing to the same database. When it comes to debugging the database I get the following error: Unable to open the physical f...

Return the uniqueidentifier with entity framework

I am using Entity Framework 3.5, while inserting a record i want to return the unique identifier with entity framework. How to do that? ...

Run multiple queries or return multiple value with entity framework

I am basically looking for a way to run a entity framwork query that will return a subset of result in a tabel as well as the total number of records in a table. I would lik eto do it with one query. I know that I can do a count, then run the querybut that looks like it makes two round trips to the database. does anyone have any ideas?...

How to display and update data in MVC2

Table Product Product Id Product Name Table ProductSupplier ProductSupplierId ProductId SupplierId Table Supplier SupplierId SupplierName I have the above 3 tables in my database, ProductSupplier is the lookup table. Each Product can have many suppliers. I am using Entity Framework. Using Web Forms it was fairly easy to display a Pro...