If I have a nested ListView, and I'm calling a related table in LinQ, how do I sort it, without resorting to the ItemDataBound event of the parent?
Pseudo Code (UPDATED WITH SOLUTION):
<asp:ListView ID="lv" runat="server" OnItemDataBound="lv_ItemDataBound" >
<LayoutTemplate>
<!-- Product Category Stuff -->
<asp:PlaceHol...
I got a problem that is just killing me. One of my CSLA object (let's say Parent) has many children (let's call them Children - a list of Child). Parent is a Editable Root (BusinessBase) and Children is an Editable Child List (BusinessListBase) and Child is Editable Child.
What I am trying to do is to do this:
Parent x = Parent.GetPar...
I need a linq expression that will find the nearest numbers (both "greater or equal" and "less or equal") in an array for a given number.
E.g.
Array - 1, 33, 66, 100
If I have the number 10, I want to return 1 and 33. If I have the number 70, I want to return 66 and 100. If I have the number 33, I want to return 33 and 66.
I could do ...
Hi,
I am calling a stored procedure through LINQ-to-SQL (yes, I know it's deprecated). I am getting back an error, but the IExecuteResult only seems to be able to provide me with a number, when I would like the full string error description (like what you would get if you executed the SQL by hand in SQL Management Studio). Alternatively...
Is it better to have one fat data context class with all the tables in it or break them into smaller classes and potentially having "single table" classes?
From organizational standpoint I feel like I shouldn't split relations over several data contexts (I don't even think it's doable). But on the other hand I think that creating a whol...
I would like to extend a class generated by Linq To Sql to initialize when a new object (=row) is created.
I want to add rows to a child table when a parent row is created.
I was hoping to use the Oncreated (partial) method do something like this:
partial class Product {
partial void OnCreated() {
// Fill default rows for...
Is there Cache preferably a distributed cache with Linq query support?
...
I am in the process of learning more about LINQ and Lambda expressions but at this stage, I simply don't "Get" Lambda expressions.
Yes ... I am a newbie to these new concepts.
I mean, every example I see illustrates how to add or subtract to parameters.
What about something a little more complex?
To help me gain a better understand...
In linq to sql i can do like this:
var q = db.Colors;
if(! string.IsNullOrEmpty(colorName))
q = q.Where(c=>c.Name.Equals(colorName));
return q.ToList();
In Db4O linq I can't do it like this because I have to start with
var q = (from Color c in db
select c);
if(! string.IsNullOrEmpty(colorName))
q = q.Where(c=>c.Name.Eq...
While analyzing some ASP.NET MVC projects I got to see anonymous types scattered all over.
HTML helpers have them:
<%=Html.TextBox("view.Address", "address", new { Class = "text_field" })%>
A lot of the return types for actions have them:
JsonNetResult jsonNetResult = new JsonNetResult
{
Formatting = Formatting.Indented,
Data ...
I am working on a web service for creating, changing and removing hotel reservations (bookings). One booking can contain several stays (a stay is a link between a room, the services ordered, etc.). Each stay has it's own time period, so you can create 3 stays in the same booking, for 3 different weeks.
My problem arises when bookings ne...
So I have my edmx made.
Then I change my database a little bit, changing a column to from being a NOT NULL to allowing NULL.
I go into my edmx, right click and choose "Update Model from Database"
Now I go into my program and it hasnt actually updated... I can't put a null in the column. What do I have to do to update the edmx prope...
Linqpad, when coding in C#, will draw a vertical line between opening and closing curly braces.
Boy, oh boy, I sure do wish Visual Studio would do this. Does it? Is there anyway to make it do it?
...
What I'm doing works, but it's just wrong, I know it.
public Profile GetProfile(int id)
{
Profile profile = (
from u in en.User where u.UserID == id
select u.Profile.FirstOrDefault()
).First();
if (profile.UserReference.Value == null)
profile.UserReference.Loa...
First, here is a picture of the relevant part of my database schema:
I have several conceptual queries of increasing complexity. Currently, I am doing these with a series of SQL queries (i.e. many back-and-forth trips from the C# code to the SQL Server), and I'd like to find a way to get these each in a single query, but doing so is ...
I am calling the LINQ extension method AsQueryable off of a generic list. It throws StackOverflowException exception when I access it. This is a similar technique used in the NerdDinner asp.net mvc demo app. What am I doing wrong?
class FakeUserRepository : IUserRepository
{
List<User> users = new List<User>();
...
I'm using Linq to SQL with SQL 2005. I'm parsing a large fixed width file and importing the data into SQL via custom entities that I have mapped to the database using property attributes.
The program runs for about 240 records before throwing this error. I've checked the columns (all four of them) and the data it's trying to put in and ...
Can anyone tell me why the following code doesn't work the way I expect? I'm trying to write an IEnumberable wrapper around a StreamReader, but when I use ElementAt on it, it reads sequential characters from the stream regardless of the index I pass to ElementAt.
The file "test.txt" contains "abcdefghijklmnopqrstuvwxyz". I would expec...
So with LINQ-to-SQL I know you can update the database from the LINQ objects and update the LINQ objects from the SQL.
I am using LINQ's entity framework (a.k.a. LINQ-to-entities) and I can update the entities from the SQL database, but I can't update the database schema by changing the entities.
This is frustrating. Is there somethin...
I could have sworn that there was an extension method already built for the Queryable class that I just can't find, but maybe I'm thinking of something different.
I'm looking for something along the lines of:
IQueryable<Entity> en = from e in IDB.Entities select e;
en.ForEach(foo => foo.Status = "Complete");
en.Foreach() would essent...