Maybe a simple question, I'm trying to get a result from a table where the Name column contains all of an array of search terms. I'm creating a query and looping through my search strings, each time assigning the query = query.Where(...);. It appears that only the last term is being used, I supposed because I am attempting to restrict th...
Hi, i am trying to obtain an item from a collection that occurs most frequently. if i were in SQL i would do something like this..
select top(1) extension from database.table
group by extension
order by count(extension) desc
but im trying to do this using linq.
Can someone assist with the translation?
so far i have this but its not ...
Hi Everyone,
I have the following script that will update the connection string across three different config files used in development.
function Main()
{
pushd
cd ..
$aomsDir = pwd
$configFiles = @( 'util\GeneratePocos.exe.config', 'src\Web.UI\web.config', 'src\Data\App.Config')
$MyAOMSEntitiesConnStr = $env:AOMS_CONN_STR
Write-...
What I need is such a simple, easy query, it blows me away how much work I've done just trying to do it in LINQ. In T-SQL, it would be:
SELECT I.InvoiceID, I.CustomerID, I.Amount AS AmountInvoiced,
I.Date AS InvoiceDate, ISNULL(SUM(P.Amount), 0) AS AmountPaid,
I.Amount - ISNULL(SUM(P.Amount), 0) AS AmountDue
FROM Invoices...
I'm designing a reporting engine for my project. The project will have several reports, each of which can be expressed as a Linq query; some will have parameters, while others won't.
Now in order to meet my clients' requirements, I need to return the results of the queries in XML format, so that they can apply an XSL transform to make ...
Hi,
I am making an application usign MVC and LINQ.
I have a controller called home which does this:
Dim notes = From x In dal.tbl_notes _
Join y In dal.tbl_note_users On y.user_id Equals x.note_id _
Select x.note, x.datestamp, y.is_owner, y.note_user_id
ViewData("notes") = notes
Return View(...
Hi, I am working with a quite tricky SQL-Query that I would like to translate to LINQ.
Do you think it is possible?
WITH ConditionalChecks AS (
SELECT c.ItemId FROM ConditionalProperties c, Properties p
WHERE c.PropertyId = p.Id AND c.IsChecked = 1 AND (
(p.SystemName = 'eatable') OR
(p.SystemName = 'diy')
)
),
...
SQLite first timer, and I want to use Linq for data access.
I made a SQLite database with sqliteadmin, and added it as a data source in VS2008.
The problem is that when i try to drag&drop a table from the server explorer to the .dbml file, i get the error:
"The selected object(s) use an
usupported data provider."
I used .NET ...
I am trying to get the week of a date from the database and compare it to a user selected value from a DateTimePicker. My users can select a day and I wrote a class that gives me the week of that day in the form 1 to 52. I am trying to select get LINQ to compare the weeks of a given date from the database to the week selected by the user...
A friend asked me how to improve some code with LINQ. How would you do a character by character comparison between two strings to count the number of matches at an index? Here's the original code, could it be improved with LINQ?
private int Fitness(string individual, string target)
{
int sum = 0;
for (int i = 0; i < ind...
Ok, so let me explain a little of what I am trying to do.
I have a table called WebsitePage that contains all of the pages on my site with some information about them. Then, I have a Customer table for all of my customers. Then I have another table called CustomerWebsitePage that stores customer values for some of the columns in the Web...
I am new to linq and am trying to create some data points from a table to graph. The three fields of importance in this table are the id, the time and the value. I am writing a query to get the average value over a set time for a chosen id. The linq I have written follows:
var value = (from t in _table
where t.Id == id
...
I have an collection of iQueryable objects.
Looking through intellisense i see 'GetElementAt(int)' but what i actually want to do is return multiple elements - so something like
GetElementAt(int startindex, int count) GetElementAt(int startindex, int endIndex).
I cant seem to see this. Any ideas?
The only other thing i can think of is...
Hello,
I am using the entity framework model to query my database and have put in a few views that I would like to use that all have the same query parameters. Rather than write a big list of case-switch statements I am wondering how to do this programmatically by passing through the view object as a parameter to my main method. In sql ...
I've been getting stuck into some linq queries for the first time today and I'm struggling with some of the more complicated ones. I'm building a query to extract data from a table to build a graph. The tables colums I'm interested in are Id, Time and Value.
The user will select a start time, an end time and the number of intervals (p...
I have a sp which builds a dynamic sql query based on my input params. I tried replicating in linq and somehow it seems incorrect.
My linq:
var result = from R in db.Committees.Where(committeeWhere)
join C in db.Employees.Where(employeeWhere) on R.PID equals C.PID
join K in db.CommitteeTypes.Where(committeesWher...
I'm experiencing an odd scenario and I'm looking for ways to figure out what's going wrong. I've got a piece of code that inserts a row into a table - the kind of thing I've done in dozens of other apps - but the end result is nothing happens on the database end, and no errors are generated. How do I find out what's going wrong?
Here's ...
I am writing an app using .NET, C#, LINQ to entities and SQL Server 2008.
I would like to pick a row randomly from a table. Is there a way to achieve this using the LINQ queries. One approach would be to get a list of rows from the table and then pick one of them randomly, which is very straight forward.
Just curious, if there is a way...
As I read the a similar question about searching SQL I realized I am very curious on how to do the same thing in Linq.
Assume a DB Table with the fields "Title", "Tags" (comma separated) and "Body" (HTML) that has been connected to a Linq2[Entities|Sql] How would you go about searching for a string across those fields.
Yes, I could b...
Hey all,
I'm wondering if its possible to join together IEnumerable's.
Basically I have a bunch of users and need to get their content from the database so I can search and page through it.
I'm using LINQ to SQL, my code at the moment it:
public IEnumerable<content> allcontent;
//Get users friends
IEnumerab...