entity-framework

Using 'Contains' Clause Like 'IN' SQL Clause in Entity Framework

I am working on a tag cloud application. There are 3 database tables. Content: ContentID, Text Tag: TagID, Name TagRelation: TagRelationID, TagID, ContentID The code below is wrong. Because 'Contains' clause doesn't take a list of parameters like the 'IN' SQL clause. Is there an alternative clause that I can use to make this code wor...

MVC 2, Entity Framework 4. Custom Generic Query. Where I put the code?

Here is my problem, I have a multilang database shema. First I want a query with this result French | English Car | NULL Etoile | Stars NULL | Monkey ... I'm pretty sure I will need to use A left join combinate with Pivot table. Where I'm suppose to put this query. In a Partial class, or I need to use the Repository Pattern to...

LINQ to Entities does not recognize the method 'System.Linq.IQueryable ...

When I try to call my repository in a Sub Select, I got this error. IGrpTextRepository rep = new GrpTextRepository(); var query = new DetailViewModel { ViewDet = (from gh in _db.Grp select new MultiDetailViewModel { Header = gh, ...

Repository integration tests

I want to implement integration tests of my Entity Framework driven repositories. The problem is how to rollback database state after tests are done. At the moment I'm planning to start transaction at test SetUp and roll it back at test TearDown. Are there any other solutions excepting manual database clearing? ...

How to determine the type of objects in a collection in C#

I am attempting to use Reflection in C# to determine at runtime the type of objects in a collection property. These objects are entities generated by the Entity Framework: Type t = entity.GetType(); PropertyInfo [] propInfo = t.GetProperties(); foreach(PropertyInfo pi in propInfo) { if (pi.PropertyType.IsGenericType) { ...

Testing Repositories in Entity Framework

Hi I'm new to EF but am trying to go by the book and create tests for my repositories. The tests fails here. desiner.cs base(global::System.Configuration.ConfigurationManager.ConnectionStrings["pij_localConnectionString"].ConnectionString, mappingSource) I presume I need to move the connection strings out of the webconfig. What is t...

entity framework get data list by role

Hi. I got: public interface IRepository<TE, TK> where TE : class, IEntityId<TK>, new() where TK : struct { IQueryable<TE> Query(); void Create(TE entity); void Update(TE entity); void Delete(TE entity); } The Query method should return a data list via Entity Framework 4 ORM. Use case: I need all august orders...

EF4 VS2010 not mapping linked tables properly

I have a pretty standard linked table setup Table1 Id - PK, seeded Table2 Id - PK, seeded Table3 Table1Id - FK Table2Id - FK For some reason, when using the designer to create the edmx in VS2010, table 1 exists already. When adding Table2 and Table3, they get added, but no relationship gets attached between Table3 and Table1. As w...

ADO.NET EF as DAL

Hi. I'm developing a project using a layered architecture. I have a DAL in which i'm using Entity Framework, a business logic layer which consumes the objects returned by the DAL and an app layer. I'm not entirely sure i'm thinking this right, so i'll just ask you what you think. My DAL is based on mappers. I have types - mappers - th...

How to use Func with Entity Data Context?

i writed below codes MyCustomer.cs must return List which is type of Customer entity. İ used Func method. I want to do this: return erpEntityCtx.Customer.Select(select).ToList<TResult>(); BUT error return to me: Has some invalid argument. i can use this: return erpEntityCtx.Customer.Select(c=>c.Name).ToList<TResult>(); However ...

How can i develop lRepository<TModel> in Manager class in Enttiy?

i try to write manager class. But i can not use that : return erpObj.Get(predicate); How can i do that? namespace Erp.BLL.Manager { public interface ILoad { List<TResult> Load<TKey,TResult>(List<TKey> list, Func<TKey, TResult> select); } public interface IRepository<TModel> { List<TModel> Get(Fun...

Delete link with jquery confirm in Asp.Net MVC 2 application

I have a table with records that has delete links. Basically I followed the NerdDinner tutorial for that part in MVC. But I don't want to have the confirm view, I'd rather have a confirm dialog, and then if confirmed let the HttPost action method delete the record directly. I have something working, but being new to both MVC and jQuery,...

Attached entity does not get update with new values when SaveChanges is called

Is there anything wrong with this code? My entity is not getting updated. public ActionResult UpdateNota(string notas) { if (Request.IsAjaxRequest()) { RegistroEntities registroEntities = new RegistroEntities(); Nota nota = JsonConvert.DeserializeObject<Nota>(notas); registroEntities.AttachTo("Notas",nota...

Filter the "Includes" table on Entity Framework query

This is for Entity Framework for .NET 3.5: I have the need to query a table and include a collection of the "many" table of a one-to-many relationship. I'm trying to filter that collection as part of the query - I'm pretty new to Entity Framework, and I'm having trouble figuring it out. Simplified example: Author has Books, and Book h...

Convert byte[] to Base64 string in Javascript

Hi, I use to render data using EntityDataSource, and I use to store customer image as byte in database, the problem is how can I convert that byte to base64 on .aspx page itself to use it as image src, is there any way to do this in javascript. ...

Null reference exception in entity navigation

I have the following EF structure: I want to get name of the every user who attended to a meeting: using(var ctx = new MyContext()) { var meeting = (from row in ctx.Meetings.Include("MeetingMessages").Include("MeetingUsers") where row.mId == 1 select row).FirstOrDefault(); foreach(var meetingUser in m...

POCO + Entity Framework with repository pattern - permission handling

Hello. I have an application that consists of 3 layers: UI: to be implemented in ASP.NET MVC Business: Holds the business logic and resource access control Repository (DAL): Implemented with POCO objects and EF, using the repository pattern. My POCO objects are shared with the upper layers. I have questions about what information/meth...

Entity Framework. How to add object to collection in Unchanged state.

How to add object to a collection so that after .SaveChanges() it hasn't inserted/updated? ...

How to make EF execute Insert Queries in the right order?

Hello, I am using the Entity Framework with a MySQL server because I want to be able to do nice and easy LINQ queries againy my MySQL database. I have a very simple problem and I'm frustrated because I can't believe that the EF is making such a horrible mistake. To simplify, I have parent and child classes, and I want to execute two in...

How can i see execute command in Entity FrameWork ?

i try to use erpCtx.Executecommand but i doesn't have method of executecommand. i think that i must add dll in Reference to show executeCommand? i need : int rowsAffected = engCtx.ExecuteCommand("insert into ENG_MAINWP Values({0},{1},{2},{3})", engArray[0], engArray1, engArray[2], engArray[3]); ...