In normal sql I could do joins on tables in different databases as long as they were on the same server (or linked servers). In linq I can't figure out how to do that. Is this possible? For example, if I have a database called db1 and another called db2. db1 has a table called people and db2 has a table called address I could do something…
I have a data base with Price_old like:
Date --- Hour --- Price
_____________________________
Jan 1 --- 1 --- $3.0
Jan 1 --- 2 --- $3.1
Jan 1 --- 3 --- $3.3
Jan 1 --- 4 --- $3.15
Jan 2 --- 1 --- $2.95
Jan 2 --- 2 --- $3.2
Jan 2 --- 3 --- $3.05
What I then have is a spreadsheet, with the same structure, that I will…
HI ,
I am going to rewrite a store procedure in LINQ.
What this sp is doing is joining 12 tables and get the data and insert it into another table.
it has 7 left outer joins and 4 inner joins.And returns one row of data.
Now question.
1)What is the best way to achieve this joins in linq.
2) do you think this affect performance (its only…
Hello,
i have some class which constructs itself from string, like this:
CurrencyVector v = new CurrencyVector("10 WMR / 20 WMZ");
it's actually a class which holds multiple currency values, but it does not matter much.
I need to change type of column in my LINQ table (in vs 2010 designer) from String to that class, CurrencyVector.
If i…
I have a console app that's geared to be automatically ran as a Scheduled Task. I use LINQ to SQL to pull some data out of the database, format it into a CSV and email it to a client. All of a sudden I am getting the error "SELECT permission denied for table", but the account I'm using to connect to the database (specified in my…
I understand that when the C# compiler sees a linq query comprehension, it basically does a straight translation to the corresponding Linq Extension methods and lambdas. i.e.
from x in list
select x.property
gets translated to:
list.Select(x => x.property)
my question is what do let clauses get translated to. for example…
I have the following view:-
CREATE VIEW tbl_adjudicator_result_view
AS
SELECT a.adjudicator_id, sar.section_adjudicator_role_id, s.section_id, sdr.section_dance_role_id, d.dance_id, c.contact_id,
ro.round_id, r.result_id, c.title, c.first_name, c.last_name, d.name, r.value, ro.type
FROM tbl_adjudicator a
INNER JOIN…
Given a simplified model like the following:
public class Enquiry
{
public virtual DateTime Created { get; set; }
public virtual Sender Sender { get; set; }
}
public class Sender
{
public virtual IList<Enquiry> Enquiries { get; set; }
}
How can you construct a Linq to Nhibernate query such that…
I am trying to reproduce a SQL query using a LINQ to Entities query. The following SQL works fine, I just don't see how to do it in LINQ. I have tried for a few hours today but I'm just missing something.
SELECT
h.ReqID,
rs.RoutingSection
FROM ReqHeader h
JOIN ReqRoutings rr ON rr.ReqRoutingID =…
I have the concept of valid/ordered transitions. So for example, it's not possible to move to status In progress from status Complete.
Current and Next in table StatusTransition are FK (StatusType.Id).
The Linq generator has created the following relations:
Child Property Name: StatusTransitions1
Parent…
I've written the following query in Linq:
var res = dc.TransactionLoggings
.Where(
x => !dc.TrsMessages(y => y.DocId != x.DocId)
).Select(x => x.CCHMessage).ToList();
This resolves to the following:
SELECT [t0].[CCHMessage]
FROM…
I'm actually using a join in linqtosql (via dblinq).
I'm trying to include a regular expression in the join part of the linq query.
from i in collectiona
join j in collectionb on Regex.IsMatch(i.name, j.jokered_name) equals true
(...)
I agree i can push the RegExp check in the…
Given a simplified model like the following:
public class Enquiry
{
public virtual DateTime Created { get; set; }
public virtual Sender Sender { get; set; }
}
public class Sender
{
public virtual IList<Enquiry> Enquiries { get; set; }
}
How can you construct…
Hi All,
Imagine a have a very long enunumeration, too big to reasonably convert to a list. Imagine also that I want to remove duplicates from the list. Lastly imagine that I know that only a small subset of the initial enumeration could possibly contain duplicates. The last…
This question is similar to http://stackoverflow.com/questions/2835192/linq-group-one-type-of-item but handled in a more generic way.
I have a List that has various derived classes. I may have something like this:
List<BaseClass> list = new List<BaseClass>() {
…
Hi guys,
I'm making modifications to a C# MVC application that I've inherited.
I have a database, and for simplicity I'll just focus on the two tables I'm working with for this linq query.
Item
ItemID Int PK
ItemName
RepairSelection (Yes or No)
RepairID Int FK
Repair…
I have a Windows 8 store application and I'm using the latest version on SQLite for my database.
So I want to return some records from the database and I want to order them by more that one column. However SQLite doesn't seem to have the ThenBy statement? So my LINQ…
Is there a way to duplicate a db record with linq to sql in c#?
Id [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Foo] [nvarchar](255) NOT NULL,
[Bar] [numeric](28,12) NOT NULL,
...
Given the table above, I would like to duplicate a record (but give it a different…
I'm using Lucene.net to build a MyListOfIds As List(Of Integer) which I then pass on to my Linq service. I then search the database as follows
Return _EventRepository.Read().Where(Function(e) MyListOfIds.Contains(e.ID)).ToList
Now I know that Lucene is already…
Hi, I have a one-to-many Linq query and I would like to sort on a property within the "many" collection. For example in the pseudo-code below, I am returned a List from the Linq query but I would like to sort / order the Products property based on the…