linq-to-entities

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 ...

LINQ to Entites: Creating comma-delimited string from many-to-one relationship

I have a couple of tables with a many-to-one relationship, and I'm trying to create a string that contains a comma-delimited string as follows. Let's call them State and City - City table has a FK to State.ID, and States belong to Countries: var foo = from item in _ctx.State where item.country_id == country_id ...

How to use LINQ on this query?

I want to convert the IEnumerable<Target> of : public class Target { public Frame BaseFrame; public Rect[] rects; } To IEnumerable<foo> of : public class foo { public Frame BaseFrame; public Rect rect; } e.g. expand the Rect[] array, IEnumerable<Target> to IEnumerable<foo>, how to write LINQ on this f...

Link To SQL Join Statement with or Clause

I have to following SQL Statement that I want to conver to LINQ Select F.FooName B.BarName From Foo F Inner Join Bar B on B.BarName = F.FooName OR B.BarName + 'hello' = F.FooName I have seen Inner joins in Link on multiple conditions with AND Clauses but not using OR The following is as far as I have gotten var myresult = from f ...

Developing enterprise level application using LINQ

Using LINQ to SQL make application development faster but dissolves the logical layers in the application. The data access layer and the business objects layers almost have no identity, they sit in the same dll. Does any one has an idea on how to develop an enterprise level application using LINQ to SQL. How do we cleanly separate the bu...

LINQ To Entities - Items, ItemCategories & Tags

Hi There, I have an Entity Model that has Items, which can belong to one or more categories, and which can have one or more tags. I need to write a query that finds all tags for a given ItemCategory, preferably with a single call to the database, as this is going to get called fairly often. I currently have: Dim q = (From ic In mCont...

LiNQ to Entities, Include less

Hi, If you are making a LinQ to entities expression for ClassA where A has a relation to ClassB like this: var temp = from p in myEntities.ClassA.Include("ClassB") where ... select p; You will get a set of ClassA:s with the reference to ClassB loaded. The thing in my case is that I dont really need to load ALL t...

How to return hierarchical anonymous type from LINQ Join?

How can I write a LINQ query that returns an hierachical anonymous type from a Join? To clarify what I mean: With WCF Data Services and Telerik WPF RadTreeView one can easily query and display hierarchical data: Dim q = _ctx1.Execute(Of NorthwindDataService.Customers)(New Uri("Customers\?$expand=Orders", UriKind.Relative)) Dim ...

WCF RIA Services - Loading multiple entities

Hello, I'm looking for a pattern to solve the following problem, which I imagine is common. I am using WCF RIA Services to return multiple entities to the client, on initial load. I want both entities to load asyncrhonously, so as not to lock the UI, and I'd like to leverage RIA Services to do this. My solution, below, seems to work....

LINQ to Entites: How and where to use OnPropertyChanging or ReportPropertyChanging events?

I'm trying to determine when a certain field is updated, and perform an action when the field changes. I'm using a custom binder for the class, and the first call in the binder is to base.BindModel(), at which point the original value is gone. When do the OnPropertyChanging and ReportPropertyChanging events get called? Is there any wa...

LINQ to Entities (Entity Framework) Join and .Include conflict

What I want to do seems pretty simple. I want to select some employers and I want to include the last 6 quarterly data records sorted by year and quarter descending. Consider the Expression: var query = from e in data.Employer.Include("EmployerQuarterly") where e.UIAccount == 22 select e; I'm on the right tra...

How to post a array of complex objects (that has a array of complex objects) with jQuery

I want to post some Products that has a ID and some Categories with jQuery. But I get a error in: Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder.BindProperty (NullReferenceException), when I add the Categories. Should not the default ModelBinder be able to bind this (without a ActionFilter or custom ModelBinder)? I tried ...

Dynamic Linq to Entities...querying date fields

I am trying to use Linq to Entities with the Linq.Dynamic library (via Scott Guthrie) and I'm having some strange issues with querying dates. var _date1 = DateTime.Now.AddDays(30).Date; var _date2 = DateTime.Now.AddDays(31).Date; var dateField = "DUEDATE"; docs = db.DOCUMENT.Where("@0 >= @1", dateField, _date1).Where("@0 <= @1", dateFi...

Linq to Entities : using ToLower() on NText fields

I'm using SQL Server 2005, with a case sensitive database.. In a search function, I need to create a Linq To Entities (L2E) query with a "where" clause that compare several strings with the data in the database with these rules : The comparison is a "Contains" mode, not strict compare : easy as the string's Contains() method is allow...

SOLVED: deploying applications that use LINQ to Entities.

HI COMUNITY!!!! I want to use L2E since it s very convenient to my company's apps, I created a demo project, the demo does run on every machine but when I, lets say, press a button that has some code that uses the entity I get this error: specified store provider cannot be found in the configuration, or is not valid. note that I get ...

OrderBy and Distinct using LINQ-to-Entities

Here is my LINQ query: (from o in entities.MyTable orderby o.MyColumn select o.MyColumn).Distinct(); Here is the result: {"a", "c", "b", "d"} Here is the generated SQL: SELECT [Distinct1].[MyColumn] AS [MyColumn] FROM ( SELECT DISTINCT [Extent1].[MyColumn] AS [MyColumn] FROM [dbo].[MyTable] AS [Extent1] ) AS [Distinct1]...

Is LINQ to Dataset subset of LINQ to EF or these two are independent?

Is LINQ to Dataset subset of LINQ to EF or these two are independent? ...

displaying one-to-many results from dynamic query

I'm using the dynamic query library and I'm trying to retrieve and access a single record from a one to many 'included' table/entity. I have the following code: var xresults = viv.tbl_user .Include("tbl_pics") .Include("tbl_user_bio") .Include("tbl_province") .Include("tbl_area"...

LINQ-to-entities - Null reference

I could swear this was working the other day: var resultSet = (from o in _entities.Table1 where o.Table2.Table3.SomeColumn == SomeProperty select o ).First(); SelectedItem = resultSet.Table2.SomeOtherColumn; I am getting a null reference exception on the last line: resultSet.Table2 is null. Not only am I sure that al...

Simple way to return anonymous types (to make MVC using LINQ possible)

I'd like to implement MVC while using LINQ (specifically, LINQ-to-entities). The way I would do this is have the Controller generate (or call something which generates) the result-set using LINQ, then return that to the View to display the data. The problem is, if I do: return (from o in myTable select o); All the columns are read f...