Is it possible to add the "DeleteOnNull=true" on a custom class instead of modifying the DBML (generated) class directly?
For example, let's say this is a part of my generated dbml class:
[Table(Name="OrderDetails")]
public partial class OrderDetail :
INotifyPropertyChanging, INotifyPropertyChanged
{
// deleted for brevity
...
I have 14 LINQ queries to resolve in one method. None of them have a base query that I could hang them from as subqueries and then store the results as properties of an anonymous type instance.
Rather than making 14 separate calls to the database, how can I ensure that they are all called in the same operation?
UPDATE
I ended up using...
Hi,
I just had the weirdest debug experience in a very long time. It's a bit embarassing to admit, but it lead me to be believe that my Linq query produces MORE results when adding an additional Where clause.
I know it's not possible, so I've refactored my offending function plus the unit test belonging to it into this:
[Test]
public...
I'm looking to learn LINQ, but I'm finding that there is a lot more to it then what I initally expected. In fact, there's so much that I'm not sure where is the best place to start. I know that there's LINQ to SQL, and LINQ to Entities, and a number of other LINQ whatevers out there.
Which is the best to start with? It seems that I see ...
I have a Dictionary and a List of keys to remove from the dictionary. This is my implementation right now:
var keys = (from entry in etimes
where Convert.ToInt64(entry.Value) < Convert.ToInt64(stime)
select entry.Key).ToList();
foreach (var key in keys)
{
etimes.Remove(key);
count--;
}
Is there somethi...
How can I write the following code more elegantly using LINQ query syntax?
var mergedNotes = new List<Note>();
var noteGroupsByUserID = notes.GroupBy( x => x.UserID );
foreach (var group in noteGroupsByUserID)
{
var sortedNotesByOneUser = group.OrderBy( x => x.CreatedOn ).ToList();
var mergedNotesForAUserID = GetMergedNotesFor...
I'm trying to figure out how to create a dynamic context, and what I mean by that is I have two databases: one for testing, and one for production. Depending on where my website is hosted, I want my context to be pointing at one of the two. So, in my web.config I have:
<add name="Testing_ChannelsEntities" connectionString="removed for b...
Given a class:
class Control
{
public Control Parent { get; set; }
public List<Control> Children { get; set; }
}
and a list:
List<Control> myControls;
Is it possible to write a linq query that will select all children & grandchildren for a given control? For example if a tree looks like this:
GridA1
PanelA1
TextBoxA...
My problem is this:
We have a very large Legacy DB with many SPROCs, Views & Tables.
The Designer is a "NO GO" b/c of the size.
I've configured SQL Metal to build the data context, but the resulting code file is so big (12MB) visual studio 2008 will not open it.
If SQLMetal would generate a new file for each class type (Table, View,...
I have created an IEnumerable list of racing drivers using LINQ from a string array as such below:
string[] driverNames = {
"Lewis Hamilton",
"Heikki Kovalainen",
"Felipe Massa",
"Kimi Raikkonen",
...
Is there a way to set the fetchmode to eager for more than one object using linq for nhibernate. There seems to be an expand method which only allows me to set one object. However I need to set it for more than one object. Is this possible? Thanks
...
I'm trying to get the n-th element out of a list of anonymous types returned by a LINQ query where n is a random number from 0 to 100. Messed around with it a while now and I'm not getting anywhere. My code (with names changed to protect IP):
var query = from Table1 t1 in theContext.Table1
join Table2 t2 in theContext.Table2
on...
I looked at this example http://msdn.microsoft.com/en-us/library/bb399420.aspx
and clicked on DataContext.CreateDatabase which brought me to this page http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.createdatabase.aspx
It says to use System.Data.Linq namespace and include the reference System.Data.Linq.
I have don...
Could any one show me how to get record from this statement
Select random employee which is not an employee of the month in the last x months
Table Employee
ID
EmployeeName
Table EmployeeOfTheMonth
ID
EmployeeID
MonthStartedDate
MonthEndedDate
Thank you very much
...
I am looking for a LINQ equivalant for the following query:
SELECT UPPER(SUBSTRING(CompanyName, 1, 1)), COUNT(*) FROM MyTable GROUP BY UPPER(SUBSTRING(CompanyName, 1, 1))
Thanks in advance.
...
How can i do this ?
where tsc.TransactionID in (from t in Transactions where ........
Eg:
var query = (from tsd in TransactionSampleDetails
join tsc in TransactionSamples on tsd.TransactionSampleID equals tsc.TransactionSampleID
join qp in QualityParameters on tsd.ParameterID equals qp.ParameterID
where tsc.Trans...
I have two tables Customers, Orders
Customers
CustomerID
FName
LName
Orders
OrderId
CustomerID
OrderDate
I want to make a linq statement that can join these two tables and get
FName, LName, Count of orders for each customer
...
I'm sure it's something really stupid, but I just don't see it..
pData.LocationHours is of type BaseLocationHoursDataSet.LocationHoursDataTable. Yet when I hover the cursor over l, all I see is "(range variable) TSource l" - why is that?? Why doesn't linq know what it's dealing with? I try the same thing with a different DataTable a...
For example:
m_lottTorqueTools = (From t In m_lottTorqueTools _
Where Not t.SlotNumber = toolTuple.SlotNumber _
And Not t.StationIndex = toolTuple.StationIndex).ToList
What algorithm occurs here? Is there a nested for loop going on in the background? Does it construct a hash table for these fi...
Hello All,
I have a procedure in SQL that I am trying to turn into Linq:
SELECT O.Id, O.Name as Organization
FROM Organizations O
JOIN OrganizationsHierarchy OH ON O.Id=OH.OrganizationsId
where OH.Hierarchy like '%/12/%'
The line I am most concerned with is:
where OH.Hierarchy like '%/12/%'
I have a column that stores the hierarch...