linq

Is there a way to get a fully executable string of the SQL that is about to be run by a Linq2Sql expression?

I know you can get the SQL, but it's paramterized without the parameters being visible. Can you get the "full" string, so to speak? ...

Caching ListView data a viable option?

Here's my scenario: 1) User runs search to retrieve values for display in ListView via LinqDataSource. 2) They click on one of the items which takes them to another page where the details can be examined, further drill-down can happen, etc. 3) User wants to go back to the original ListView results to select another item for inspection. ...

Bindable LINQ (BLinq) in VB.NET

I cannot get Bindable LINQ to work with VB.NET for the life of me. How do I get the .AsBindable extention to appear? Sample code: Class TestList : Inherits Bindable.Linq.Collection.BindableCollection(Of TestItem) 'Some Helpers and stuff' End Class Class TestItem 'Some Properties' End Class Imagine I magically come up with a coll...

Is there a good way to detect empty results in a Linq-To-Entities query?

The only way I know of is awkward: 'check for empty return Dim count As Integer = (From s In myEntity.employee Where employeeID = myEmployeeIDVariable).Count 'If there is a record, then process If count > 0 Then Dim r = (From s In myEntity.employee Where employeeID = myEmployeeIDVariable).First() . . . do stuff . . . End If ...

nhibernate Linq

I am using the old linq provider for nHibernate and waiting patiently for the new one to come out. I am sure it will save me much pain. Anyway, I have a problem with the code below as it generates a "Object reference not set to an instance of an object". The line "c.Disciplines.Any(d => disciplines.Contains(d))" is the one causing the pr...

Replacing Entity in LINQ

I'm using an Edit View in ASP.NET MVC and after an edit it returns the Edited Entity back. What's the best way to get the edited values back to the databse. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, Movies EditedMovie) { var orginalMovie = _db_linq.Movies.First(e => e.Id == id); if (!Mode...

Linq To SQL : Modeling Associations

I have three tables Projects, Users and ProjectMembers. The ProjectMembers table is a mapping table and has only two columns ProjectId and UserId. In my object model i have two classes Project and User. The Project class has a property IEnumerable<User> Members I am using an external xml map file for mapping linq to sql associations. I...

Parsing an Excel file in C#, the cells seem to get cut off at 255 characters... how do I stop that?

I am parsing through an uploaded excel files (xlsx) in asp.net with c#. I am using the following code (simplified): string connString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";"); OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet...

Sorting jqGrid in ASP.NET MVC client view with jQuery and LINQ-to-Entities

I'm a jQuery noob, so I'm sure I'm missing something simple here. I've got the jqGrid working with an action that creates JSON data from a LINQ-to-Entities operation. But when I click on the column headers in the browser, the rows don't sort. The ascending/descending indicator shows up, but nothing else happens. The necessary JavaScrip...

LINQ to XML Newbie: Moving Nodes From One Node To Another

Greetings! I have an XElement object that contains the following: <Root> <SubSections> <SubSection id="A"> <Foo id="1"> <Bar /> <Bar /> <Bar /> </Foo> <Foo id="2"> <Bar /> <Bar /> </Foo> ...

How to Query and count an Employees table and Project table in one linq query in silverlight?

I have two tables an employee table and a project table and I am looking to bring back a count of the number of employees assigned to each project. In the employee table I have employeeIDs and projectIDs, and in the projects table I have projectID, name, department, notes, etc. I am looking to bring back the following information and d...

Run a method on all objects within a collection

So I have a collection of Razzies created from a Collection of Bloops. I retrieve this collection using a Linq query. Reference:http://stackoverflow.com/questions/923238/linq-select-certain-properties-into-another-object for the query. I would like to know if it is possible to run a method on all of the newly created Razzies before re...

When does Linq's Take, take the results?

Does it take the number specified and stop while querying or after the entire list is already in the collection? WHat performance benefit if any is there when uysing 'take'? ...

How to write this query in LINQ?

Following query is used for Getting Categories and one news for each category. How can I write this query using LINQ SELECT * FROM News n where n.NewsID IN (SELECT TOP 1 NewsID FROM News v WHERE v.CategoryID = n.CategoryID ORDER BY CreatedOn DESC) Thanks in advance. ...

LINQ - NOT selecting certain fields?

I have a LINQ query mapped with the Entity Framework that looks something like this: image = this.Context.ImageSet .Where(n => n.ImageId == imageId) .Where(n => n.Albums.IsPublic == true) .Single(); This returns a single image object and works as intended. However, this quer...

LINQ: Condition in table and in related table

I have some items called tickers which can be created and subscribed to. When they are created, they have a scope of 1:private or 2:public. Public tickers can be subscribed to by anyone and private tickers can be subscribed to by owner invitation. I want to use LINQ to get the tickers created by a user (ie: with a certain owner id) whic...

How do I work with an XML tag within a string?

I'm working in Microsoft Visual C# 2008 Express. Let's say I have a string and the contents of the string is: "This is my <myTag myTagAttrib="colorize">awesome</myTag> string." I'm telling myself that I want to do something to the word "awesome" - possibly call a function that does something called "colorize". What is the best way ...

Problem: Failed to load viewstate.

I am making a web site for my college project. The project is website thats gets everything from web service. Can somebody tell whats going on, and how i fix it ? On one of my pages i have ListView control to display product items, and Pager on same page. On the first time page renderes fine and everything is displayed. When i click o...

Trying to develop a new extension method

Hi, I'm using the Entity Framework and I developed this extension method: public static IQueryable<TResult> Like<TResult>(this IQueryable<TResult> query, Expression<Func<TResult, string>> field, string value) { var expression = Expression.Lambda<Func<TResult, bool>>( Expression.Call(field.Body, typeof(string).GetMethod("Con...

LINQ query for a forum

Hi, I'm coding this forum and since I'm new to LINQ I ran into this problem when the user hits the main page. I want a table displaying a list of forums like this: Forum --- Topics (count) --- Posts (count) --- LastPostUserId --- LastPostTime I have the following SQL tables: Forums: ForumId (int32), Title (string), Description (str...