linq-to-entities

LINQ Expression In Subgroups

public class ErrorLogModel { public int UnitID { get; set; } public string Address { get; set; } public IList<HardwareLogModel> _Hardware { get; set; } } public class SPLHardwareLogModel { public Guid HardwareID { get; set; } public string HardwareDesc { get; set; } public string HardwareStatus { get; set; }...

Saving and Retrieving Entities of different types using LINQtoSQL

Disclaimer: Bit of a C# newbie - first Software Dev gig in awhile after being in QA for a couple years. I realize flavors of this question have been asked before (inheritance in LINQtoSQL and the like), but I'm hoping I ask the question differently. In my database, I will have a super-type of "Event" and multiple sub-types: Conferenc...

Aggregate functions with a left outer join in LINQ to Entities

I've been looking through related LINQ questions here trying to figure this one out, but I'm having some trouble converting a SQL query of mine to the equivalent LINQ to Entities version. select companies.CommpanyName, job.Position, count(offers.jobID) As Offered, job.Openings, job.Filled from jobs left outer...

linq to entity - include with lambda expression

I have a lite problem i don't really know how to fix. In my example below i would like to select a list of ProductCategories with ProductItems that are active. public IEnumerable<ProductCategory> ListProductCategories() { return _entities.ProductCategorySet.Include("ProductItems").Where(x => x.ProductItems.Active == ...

Can someone explain why these two linq queries return different results?

Hi folks, I have two linq (to EF4) queries, which return different results. The first query contains the correct results, but is not formatted/projected right. the second query is what i want but it missing some data. Schema Query 1 var xxxx = (from cp in _connectedClientRepository .GetConnectedClients(new[] { "LogEntr...

LINQ to Entites: Filtering list based on another list

Using LINQ to entities, I'm trying to filter a list based on another list. My first list looks like: IQueryable<FooViewModel> allFoos = from foo in ctx.Foo select new FooViewModel { code = foo.Code, ...

Using LINQ with IBM i

Has anyone been able to use LINQ with the IBM i? That is without having to write a custom provider? ...

How can i use Linq / Linq to Sql to do this?

Hi folks, I have an audit table and I'm trying to use Linq to figure out how to grab all the people's more recent audit actions. I'm just not sure how. Sample Schema Audit Table (technically it's actually a view) AuditId UserName Action CreatedOn 1 Bob Action1 2000-01-01 2 Bob Action2 2000-01-...

Getting exception on production server on just one wcf web service

I am getting this exception on just this service. I am using Linq to entities with Data Contracts named DeviceRequest and DeviceResponse. An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.Servic...

Insert multiple records using Linq to Entities (EF)

I have a map table (tblUserRoles) which can contain multiple records. When i insert only one record using L2E it saves but when try to save multiple records it gives exception. I am saving like this: foreach (tblUserRoles u in InsertUserRole) { EntityHelperUtil.AddObject(context, "tblUserRoles", (IEntityWithRelationships)u); ...

Linq to Entities: Next Value in Sequence

im working on a LINQ to Entities project for school, i am working with a db2 database that generates key values through a generated sequence eg. INSERT INTO STUDENT VALUES(NEXT VALUE FOR STUDENT_NUM, 'Raphael', 'Joasia'); is the there an equivalent to the NEXT VALUE operator in LINQ to Entities that will do the same or will i need to c...

Linq OrderBy breaks with navigation property being null.

Working with four tables. Users -> has basic user info including a userid and a departmentid (int) Groups -> basic group info including a groupid GroupsMembers -> table that has the relationship between a group and it's members, many to many relationship, so groupid and userid are the columns Departments -> basic department info includi...

Linq to entities : Unions + Distinct

I don't know how I can do several union with a distinct. When I use .Distinct with an IEqualityComparer an exception in threw : LINQ to Entities does not recognize the method 'System.Linq.IQueryable' My code is var union = query.Union(query1).Union(query2); union = union.Distinct(new EqualityComparerTransaction()); ...

Instructing Linq to Entities to Parse the Result of a Function, Not the Function Call

I have an function outside my EDM that I would like to include in some of my Linq to Entities expressions. The function returns an IEnumerable of Int. An example of how I might use it is: context.Employees.Where(e => GetValidEmployeeIds().Contains(e.EmployeeId)); The function GetValidEmployeeIds is the function that is returning the I...

Linq to Entities : How to filter master table rows based on child rows properties

I have a master table Person and a detail table Events I need to filter master table rows based on child row property SomeId. Could anyone please show me how to do it ? Thanks in advance! ...

How do I retrieve only certain subobjects in LINQ?

I have an entity object (Company) which has 1 or more subobjects (CompanyRevision) represented as a non-null FK relationship in the database. Using LINQ, I want to get all the Companies from the database, but I also only want the latest CompanyRevision for each company. This is how I do it today, but I have a feeling this could be done u...

Linq to entities multiple WHERE clause &&

In the code bdehind && syntax does not work, any ideas? Entities ctx3 = new Entities(); var uniqueQuote = from quot in ctx3.Quotes.Include("aspnet_Users").Include("Enquiries") where quot.Enquiries.EnquiryId == selectedEnquiryId && quot.aspnet_Users.UserId == currentUserId orderby quot.QuotePrice select quot; Error 2 Del...

Returning Entity Data Model Entities as JSON data

I noticed people wrote about this circular reference problem quite a bit before but no solution was ever posted. I'm talking about this error: "A circular reference was detected while serializing an object of type 'DocInvoice.Models.Clients'." Has anyone tried serializing it to JSON with Json.NET library? If I have Linq to entities q...

better EdmGen2?

Hi, I'm using the microsoft EdmGen2 to generate my edmx file from my database. The tool works great, but there is one things missing - it doesn't support function. Is there a way to map all the stored procedures to be functions? Also, if i'm editing it manually, the next time im running this tool, i'm losing all those changes. my ques...

Linq to entities : Stored procedure + set navigation properties

Hello, I set an object entity with a stored procedure, but the navigation properties are always equals at null ... The aim is to include or join an external entity. Any idea ? Thanks ...