I'm fairly new to LINQ in general but I've managed to figure things out so far to get the result I want/need. The LINQ2SQL query below produces the desired results in which there are Location objects, each with their own collection of Units. The initial variable declarations are done to setup the values that I need to query from and shou...
I'm stuck on translating a left outer join from LINQToSQL that returns unique parent rows.
I have 2 tables (Project, Project_Notes, and it's a 1-many relationship linked by Project_ID). I am doing a keyword search on multiple columns on the 2 table and I only want to return the unique projects if a column in Project_Notes contains a key...
Consider the following stored procedure:
SELECT * FROM Customers;
SELECT Customer.Id, Customer.Name, Order.Total, Order.DateOrdered
FROM Customers INNER JOIN Orders ON Customers.Id = Orders.CustomerId;
The procedure obviously returns two result sets which I'm trying to retrieve with this partial class method:
public partial class DB...
If I have a structure like this
Albums
- Album
- Discs
- Tracks
and I want to order a collection of albums by the title of the first track on the first disc.
Is there something similar to the following I could do (keeping in mind I need to use the OrderBy extension method that accepts a string)?
alb...
Hi all -
I'm trying to bind a gridview to a linq to sql query that's using a stored procedure. When I run the page, i get the following error:
Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.
var db = new TableItemDataContext();
var q = db.sp_SearchForItems("1","2","3","4");
GridView1.D...
my data looks like this in the table:
ID Name Parent ID
--- ---- ---------
1 Mike null
2 Steve 1
3 George null
4 Jim 1
I can't figure out how to write a linq to sql query that will return the results with the parent rows grouped with their child rows. So for example this is the result I...
Lets say I have this table:
PetID Name Age Weight
How can I in a Linq2SQL get the name, age and weight of each pet that is the heaviest in its age group?
So if I have one pet of age 5 and four pets of age 2, I would like the Name, Age and Weight of the one that is age 5, and the one of the four with age 2 that is the heaveie...
Does anyone know the equivalent of ISDATE() in LINQ to SQL query syntax? I've got a varchar field in SQL that contains dates and I need to filter out the non-date rows.
was hoping for something like this:
var query = SomeDataContext;
query = from p in query
where p.ISDATE(field1) == true;
select p;
also, how would one cas...
I am having a problem determining how c# and LINQ solve the common problem of handling a data structure that does not necessarily return a table structure, but instead a resultset.
I have a stored procedure that works, and have included it in my DBML
[Function(Name="dbo.p_GetObject")]
public int p_GetObject([Parameter(Name="ObjectType"...
The box this query is running on is a dedicated server running in a datacenter.
AMD Opteron 1354 Quad-Core 2.20GHz
2GB of RAM
Windows Server 2008 x64 (Yes I know I only have 2GB of RAM, I'm upgrading to 8GB when the project goes live).
So I went through and created 250,000 dummy rows in a table to really stress test some queries that L...
I have a LINQ to SQL entity called Job which is just a simple table in SQL. Most of the time it works for what I need but occasionally I need more fields to be populated in this entity. I know I can use partial classes to add new fields to the LINQ generated class, but my question is how do I populate this extra data? For example, I have...
Consider my Event class, and that i store DateTime's in the DB as UTC dates. I simply want to return a filtered range based on the current date in a particular time zone - easy right?
This works fine:
IQueryable<Event> test1 = this.GetSortedEvents().Where(e => e.FinishDateTime.Date >= DateTime.UtcNow.Date);
This also works fine:
IQ...
Is it possible to cancel a linq2sql query? Like if I have built a query that takes a while to run, I would like it to be possible for the user to cancel it. Does anyone have any good ideas on this?
...
when i use Linq2Sql i can filter a table by using a lambda-expression in the DataLoadOptions.AssociateWith method.
i use this for filtering the used language - so i have a language table with all languages and a object table containing objects.
like:
DataLoadOptions opt = ...;
opt.AssociateWith<DB.Objects>(o => o.Language.Where(p => p...
Hi,
i have a LoginWindow with username and password to access in the software after that the user authenticated i want show in the next window(the mainWindow of the software) the name of the user authenticated in a TextBlock ...i show a code snippet of my LoginWindow:
public partial class Window1 : Window
{
public Window1...
I have two tables say A and B.
A cols are GUID, someintVar, someMoreIntvar
B col are GUID, someItemNO, SomeItemDesc
Now for one GUID I will have only one row in Table A. But I can have multiple rows for the same GUID.
Now I want to query the database based on GUID and select values in a class.
This class will have a list that will hold ...
I have this Linq to SQL query sequence that is basically returning a search on a table called PROJECTS. and I'm taking advantage of the deferred execution to slowly build it up.
var query = from p in objDBContext.PROJECTs
where (p.PROVIDER_ID == cwForm.productForm)
select p;
query = from p in query
where p.SubmittedDate >= cwForm.beg...
I am trying to use the Extensibility Method Definitions from my datacontext.designer.cs file to do some validation.
So I created a new file and added this code:
public partial class LawEnforcementDataContext : System.Data.Linq.DataContext
{
partial void InsertCourse(Course instance) // this definition copied from generated file
...
I am using a similar approach to others in keeping my LINQ objects in my LINQ data provider and returning an IQueryable to allow filtering etc. This works fine for filtering a simple object by it's ID or other property, but I am having a problem with a join table object that is composed of other child objects
//CoreDBDataContext db...
I didn't see any questions that asked this previously so here goes:
Once you made (or had) the decision to start using LINQ to SQL how long did it take you to learn it's ins and outs?
We're looking at using it at my organization but my superiors are concerned with the initial time cost (learning it). Hours would be the most useful of a...