I have a fairly complex Linq query:
var q = from eiods in LinqUtils.GetTable<EIOfficialDesignee>()
let eiodent = eiods.Entity
join tel in LinqUtils.GetTable<EntityTelephone>()
on new { EntityID = eiodent.ID, TelephoneType = EntityTelephone.TTelephone.Office } equals new { tel.EntityID, tel.TelephoneType }
...
I'm new to LINQ and LINQ to SQL and don't understand what's wrong with this code. The Excetpion.Message I get is "Query operator 'Last' is not supported." What I'm trying to do is get the earliest LastActivityUtc out of the latest 100. The code follows.
var postTimes = from post in db.Post
where p...
To Set up the scenario, Lets say I have 100000 rows in the table and it grows more and more each day. This queue currently takes over 2 seconds to retrieve only about 40 or 50 rows from the table.
The data in this table are grouped by DateTime references so I start off grouping all the data by DateTime because this is the only equal va...
var query = from C in db.clients
join O in db.orders on c.clientid equals O.clientid
join P in db.products on O.productid equals P.productid
select new {C,O};
I want to perform a search based on the above join. The input param could be
C.ClientID and/or P.ProductName and/or P.ProductType and/or O.ShippingType
How woul...
I started out with this question, which I sort of answered there, and now I'm asking the more fundamental question here. I've simplified the query down to this:
var q = from ent in LinqUtils.GetTable<Entity>()
from tel in ent.Telephones.DefaultIfEmpty()
select new {
Name = ent.FormattedName,
Tel = te...
I'm guessing most of us have to deal with this at some point so I thought I'd ask the question.
When you have a lot of collections in your BLL and you find that you're writing the same old inline (anonymous) predicates over and over then there's clearly a case for encapsulation there but what's the best way to achieve that?
The project...
Hi
I want to load some data with a SP.
I've put a SP in a Linq to SQL Class and I don't know how to use it for loading it's data in a datagrid.
In LinqToSqlDomainService I can't figure out how to call a SP.
What steps should I use.
Any samples of this ? All samples use a table.
Thank's
...
Hey, what's the easiest way to use a file-based database with LINQ in C#? It would be best if I could use it without installing extra components.
EDIT: I want to use it for a file index. Not the whole file system, but the database should be not too slow and not too big.
...
In my database I have stored images in the "image" data type, showing up as a binary code.
I now want to retrieve all images from one column and diplay them on a asp.net page with C#.
databaseDataContext db = new databaseDataContext();
var images = from Picture p in db.Pictures
select p.pictureThumb;
then I use t...
Does anybody know an example of correct many-to-many implementation in Linq-to-Sql?
Usually i use intermediate entity (e.g. CustomerProducts) in DataContext, and join it at every query.
The idea is to hide intermediate entity from object level by adding custom properties to partial classes - use collections like IEnumerabe Customer.Prod...
Expression<Func<Employee, bool>> employeeWhere = R => true;
employeeWhere = R => R.PositionCode == "M";
employeeWhere = R => R.IsActive; //want only ones which are true
Will the above build me a query of this :
SELECT * FROM EMPLOYEE
WHERE POSITIONCODE = "M" && IsActive = 1
This is what I want to return
var result = _db.Employ...
Based on my question from yesterday:
link text
if I had to append to my existing 'where' expression, how would i append?
Expression<Func<Client, bool>> clientWhere = c => true;
if (filterByClientFName)
{
clientWhere = c => c.ClientFName == searchForClientFName;
}
if (filterByClientLName)
{
clientWhere = c => c.Clie...
I have a List of Dictionaries that have keys of type string and values that are ints.
Many of the dictionaries have the same keys in them but not all of them.
So my question is: using LINQ how would I find the maximum value associated with each distinct key across all of the dictionaries?
So for example given the following input:
var...
Which is more efficient?
//Option 1
foreach (var q in baseQuery)
{
m_TotalCashDeposit += q.deposit.Cash
m_TotalCheckDeposit += q.deposit.Check
m_TotalCashWithdrawal += q.withdraw.Cash
m_TotalCheckWithdrawal += q.withdraw.Check
}
//Option 2
m_TotalCashDeposit = baseQuery.Sum(q => q.deposit.Cash);
m_TotalCheckDeposit = baseQuery....
What I have is a set of users with join dates and I want to use GoogleChartSharp to create a chart showing how many users have joined each month.
So I have this set of dates (US format) in a list:
01/01/2009
02/01/2009
02/12/2009
03/02/2009
03/12/2009
03/22/2009
Googlechartsharp requires me to do someth...
I have a query that works fine when using an anonymous type but as soon as I try to un-anonymize it it fails to select all values into the class.
here is the linq i'm using (in combination with Subsonic 3):
var producten = (from p in Premy.All()
join pr in Producten.All() on p.dekking equals pr.ID
where p.kilometragemax >= 10...
I need to update values but I am looping all the tables values to do it:
public static void Update(IEnumerable<Sample> samples
, DataClassesDataContext db)
{
foreach (var sample in db.Samples)
{
var matches = samples.Where(a => a.Id == sample.Id);
if(matches.Any())
{
var match = matches.Fi...
First I have to say, that I am a newby using LINQ. Actually I never used before, but I am having a task where I need to filter a DataTable, using values that will come from a List.
So I will like to know if it's possible in LINQ to query on a Datatable using values in the List as Filter values. Some one can give me some hint's
Thank you...
I need to get the products in the system that match certain criteria.
How should i decide if I should write an HQL and get all products that match the criteria from DB or write a Linq query directly to the main List that contain all products in the system.
Which should be better performance vise
...
Hi
I have 2 tables that have a relation ship to each other
Table A has 1 to many relationship with table B
so this make a navigation property into each.
Now I need to check a value from Table A(userName) and I need to check a value from table B(ClubId).
So in my mind it would be something like
Join the tables together
Where A.userN...