Hi,
Given a simple schema e.g. PurchaseOrders { OrderId, Total, LineItemCount }, I want to generate a simple query for some simple stats like below:
select sum(lineitemcount) as totalitems, sum(total) as totalsales
from purchaseorders
However in Linq to Sql I am struggling to get this into one query.
At the moment I have this:
deci...
I'm using a LinqDataSource to populate a basic GridView in ASP.NET. The user has the ability to filter the results, so I use a few WhereParameters and the Where within the LinqDataSource.
My client has requested an option to export the filtered results to a file. Easy enough to pipe the data into a file, but I would prefer not to rewrit...
I have to search a list of strings in CityList and if it contains all search strings
then it should return true otherwise false.
When i search "London","Dallas" against CityList it should return false,because
"Dallas" is missing in CityList.
var CityList=new string[] { "London","Paris","Houston","Mexico","Budapest"}
var search =new s...
Hi,
I'm trying to get Entity Framework to select an object and filter its collection at the same time. I have a JobSeries object which has a collection of jobs, what I need to do is select a jobseries by ID and filter all the jobs by SendDate but I can't believe how difficult this simple query is!
This is the basic query which works:
...
I'm trying to figure out why it does not liking my checks in the All():
itemList.Where(x => itemList.All(x.ItemType != ItemType.Test1 && x.ItemType != ItemType.Test2)).ToList();
The type arguments for method 'System.Linq.Enumerable.All<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,bool>)' cannot be i...
Suppose I have a table Person(PersonID, Name, ....). Then I use EF to create a Entity model and then create DomainService based on Ria Service. At client side(sliverlight), I try to create a dynamic linq for filter function. What I did is:
q = EntityQuery<MyData.Person>
q = q.Where(p=> p.Name.Contains(NameVar));
That is fine. Then I h...
I know how to do this via streamreader and read to the end of line, but was curious if there was a fancier way of going it (for the sake of learing).
filename: blah.csv
File layout is simple:
"Some234234 ", 234
"blahblha234234 ", 2322
I want to load this into a dictionary (the second part should be a int, but I will pars...
I have a collection of integer values in a List collection.
I want to call a function for each value in the collection where one of the function's argument is a collection value.
Without doing this in a foreach loop... is there a way to accomplish this with a lambda/linq expression?
something like... myList.Where(p => myFunc(p.Value));...
I am trying to make a log viewer displaying events from different sources but ordered by a time stamp. I have a felling I can use C# Linq for this but how ?
example: I have one list of events read from files into a strig list sorted by a datetime stamp.
Another source of events are database inserts for which I use Linq to extract the...
In my App i when debuging a have this exception:
{"Operation could destabilize the runtime."} in the foreach loop:
foreach (var item in Model)
when i hover the model in debugmode the first time
i says :
ResultView=>Expending the result view will enumarate the enumarable
base=>Operation Could not destabilize the runtime...
Can't i delete bulk objects like
List<Person> prn = new List<Person>();
prn.Add(new Person { Id = "P007", name = "Andrew"});
prn.Add(new Person { Id = "P009", name = "Bernold"});
prn.Add(new Person { Id = "P010", name = "Hare"});
PersonDB.Persons.DeleteAllOnSubmit(prn);
PersonDB.SubmitChanges();
I receive error
Cannot remove an entit...
Hello,
I've got a Stored Procedure and i'm trying to convert it to a Linq to LLBLGen query. The query in Linq to LLBGen works, but when I trace the query which is send to sql server it is far from perfect.
This is the Stored Procedure:
ALTER PROCEDURE [dbo].[spDIGI_GetAllUmbracoProducts]
-- Add the parameters for the stored procedure...
How to translate
select *from
(
select EmployeeID,FirstName,LastName,Region from Employees where city
in ('London','Seattle')
)
x
where x.Region is not null
into Linq Equivalent.
I tried (But null values also get selected)
LinqDBDataContext Context = new LinqDBDataContext();
var query = from emps in
...
How to check multiple cases in Linq ( to classify "over paid","under paid","medium pay")
Sql
select id,name,salary,
case when salary <=1500 then 'under paid'
when salary >=3500 then 'over paid'
else 'medium pay' end as status
from Person
Linq
var q =
context.Persons.
Select(c =>
...
Hello
I have this lambda expression
Me.SubcriperGrd.ItemsSource = _
source.Where(Function(p As subscripers) p.Navn Like navn)
where i should filter the grid data based on the typed input in a txtbox
It returns the result when i type the full name but it doesn't filter the data as i
type along in the txt field
what am i missin...
How to specify descending in extension method
var qry=from p in context.Persons
orderby p.salary descending select p;
extension method
var qry=context.Persons.OrderBy(c=>c.salary);
...
Hello,
I am trying to use the attach method to update an entity that was retrieve via a stored proc.
The stored proc is set up to return a specific instance, which is present in my dbml. The retrieval works as expected and returns a fully populated object. The reason I need to use a stored proc is that I need to update a property on t...
Hi,
I have a book lending system written with ASP.NET, VB.NET and LINQ to SQL. I want the web app to send the e-mail reminder about the due date to the borrower before the book is over-due. Should I write a desktop app to check the due date or there's another way around to send e-mail reminder?
Thank you for any suggestion.
...
Hello all. I have an XML file with property groups and properties. I want to retrieve the property groups, print the Name attribute from that element, and then print the child properties of said property group below that entry.
Example XML file:
<?xml version="1.0" ?>
<XMLDocument xmlns:ns="http://www.namespace.com/ns">
<ns...
I want to return the depart number that is not found Employee Table by comparing Department table.
Person Table
ID name salary job commision DeptID
--------------------------------------------------------------
P001 Jon 2000 Manager NULL 1
P002 Skeet 1000 Salesman 2000 1
P003...