linq-to-entities

How can I return IEnumarable data from function in GridView with Entity Framework?

protected IEnumerable GetPersonalsData() { // List<Personals> personel; using (FirmaEntities firmactx = new FirmaEntities()) { var personeldata = (from p in firmactx.Personals select new { p.ID, p.Name, p.SurName }); return personeldata.AsEnumerable(); } } I want to send GetPersonelData() into GridView DataSourc...

Linq SqlMethods.Like fails

I'm following the tips here, trying to leverage the statement that the sql doesn't get created until the enumerator is tripped. However I get the following error on the code below. I'm using Linq2Entities, not linq2sql. Is there a way to do this in Linq2entities? Method 'Boolean Like(System.String, System.String)' cannot be used on...

LINQ to Entites with SQL 2000 issue

Hi! I'm using Linq to Entities. I have the following query in my code, it includes left outer Join: var surgeonList = (from item in context.T1_STM_Surgeon.Include("T1_STM_SurgeonTitle") .Include("OTER").Include("OSLP") join reptable in context.OSLP on item.Rep equals r...

LINQ to Entity, joining on NOT IN tables

My brain seems to be mush right now! I am using LINQ to Entity, and I need to get some data from one table that does NOT exist in another table. For example: I need the groupID, groupname and groupnumber from TABLE A where they do not exist in TABLE B. The groupID will exist in TABLE B, along with other relevant information. The tables ...

Is writing eSQL database independent or not?

Using EF we can use LINQ to read data which is rather simple (especially using fluent calls), but we have less control unless we write eSQL on our own. Is writing eSQL actually data store independent code? So if we decide to change data store, can the same statements still be used? Does writing eSQL strings in your code pose any seriou...

LINQ to Entities pulling back entire table

In my application I'm pulling back a user's "feed". This contains all of that user's activities, events, friend requests from other users, etc. When I pull back the feed I'm calling various functions to filter the request along the way. var userFeed = GetFeed(db); // Query to pull back all data userFeed = FilterByUse...

LINQ Query Returning Multiple Copies Of First Result

I'm trying to figure out why a simple query in LINQ is returning odd results. I have a view defined in the database. It basically brings together several other tables and does some data munging. It really isn't anything special except for the fact that it deals with a large data set and can be a bit slow. I want to query this view ba...

LINQ Extension methods on child

I created a LINQ extension as talked about here. But apparently, it does not work with queries on the child. As seen in the code below: return (from p in repository.GetResources() where p.ResourceNames.Any(r => r.Name.WhereIn(arg => arg.Name, "PartialWord")) select p).ToList(); What I want to ac...

Linq: the linked objects are null, why?

Hello, I have several linked tables (entities). I'm trying to get the entities using the following linq: ObjectQuery<Location> locations = context.Location; ObjectQuery<ProductPrice> productPrice = context.ProductPrice; ObjectQuery<Product> products = context.Product; IQueryable<ProductPrice> res1 = from pp in productPrice ...

How to use Linq to select and group complex child object from a parents list.

How to use Linq to select and group complex child object from a parents list. I have an OrderList each of order object has a OrderProductVariantList(OrderLineList), and each of OrderProductVariant object has ProductVariant, and then the ProductVariant object will have a Product object which contains product information. My goal is to ...

Linq to NHibernate wrapper issue using where statement

I'am using wrapper to get some data from table User IQueryable<StarGuestWrapper> WhereQuery = session.Linq<User>().Where(u => u.HomeClub.Id == clubId && u.IsActive).Select( u => new StarGuestWrapper() { FullName = u.Name + " " + u.LastName, ...

Which one can have better performance - LINQ to EF or NHibernate?

I want to start working on a big project. I research about performance issues about LINQ to EF and NHibernate. I want to use one of them as ORM in my project. now my question is that which one of these two ORM can get me better performance in my project? I will use SQL Server 2008 as database and C# as programming language. ...

Implement LINQ to Entities unsupported method

Hi! LINQ to Entities has many LINQ methods marked as "Unsupported" (http://msdn.microsoft.com/en-us/library/bb738550.aspx). Is any way to implement some of these methods by hands? Or I should wait next release of EF? I'm especially needing this method: IQueryable<TResult> Select<TSource, TResult>(this IQueryable<TSource> source, Expr...

how to use Foreign key in L2E or EF when needs insert?

I know during the retrieve, I can use Include() to load related Entities (http://stackoverflow.com/questions/2632323/how-to-use-foreign-key-in-l2e-or-ef). but when I want to save or insert data, how to handle those reference Entities? ...

How to cache L2E entity without attach/detach?

The following code will select a key/value table in the DB and will save the result to the cache: using (var db = new TestEntities()) { if(Cache["locName_" + inventoryLocationName] != null) return Cache["locName_" + inventoryLocationName]; var location = db.InventoryLocationsSet.FirstOrDefault( i => ...

Linq to Entities and POCO foreign key relations mapping (1 to 0..1) problem

For my ASP.NET MVC 2 application I use Entity Framework 1.0 as my data access layer (repository). But I decided I want to return POCO. For the first time I have encountered a problem when I wanted to get a list of Brands with their optional logos. Here's what I did: public IQueryable<Model.Products.Brand> GetAll() { IQueryab...

L2E for insert, update, delete

I am using .Net3.5. Just wondering my understanding about the insert, update, delete are correct when use L2E. For insert, we need two statements: context.AddObject("entityName", newRow); context.SaveChanges(); For update, we only need one statement: context.SaveChanges(); For delete, we need two statements: context.DeleteObject...

LINQ and SQL performance issue when working with Membership

I am using ASPNET membership with 50000 records, and we have another table called "scm_Users" which has exactly number of records, they are NOT linked by any key. I have a simple SQL: select * from dbo.aspnet_Users a, dbo.scm_Users b where a.UserName = b.UserName I can get 50000 records in less than 1 second. In LINQ, (using Entity F...

Error: “An entity object cannot be referenced by multiple instances of IEntityChangeTracker"

Hello, I'm currently using the repository pattern in an ASP.Net MVC project and have the following code: partial class Timesheet : ITimesheet { TimeSystemDBEntities _db; public Timesheet() { _db = new TimeSystemDBEntities(); } . . ...

How to model localized items

I'm currently designing a e-commerce solution. One of the primary requirements is for the store to support localized item details. The same store must be able to support multiple languages via the user's language selection and/or browser preference. I have two tables: Item (id, sku, price, ...) ItemDetails (item_id, language, ti...