Hello everybody,
can someone please explain the difference between these 2 pieces of code:
var temp = (from c in Context.SomeTable
select new SomeObject { name=c.Name, created = c.Created}).ToList();
and this :
var temp = (from c in Context.SomeTable select c);
foreach(SomeTable t in temp)
{
SomeObject so = new SomeObjec...
I'm starting with linqToSql and I still have some problems making my queries.
For example, I want to retrieve in the same query two values, a subset of elements, and an integer with the count of the elements. This is how I did it separately:
int totalElements;
IEnumerable<ClsTax> result;
result = (from t in db.tax
sel...
How can i use LINQ with ServiceModel.Channels.Message? I'd like to use LINQ to the SOAP message body.
I initially tried doing this:
XElement elem = XElement.load(message.GetReaderAtBodyContents());
But that piece of code complains that XMLReader should be EOF after the read operation. What is the correct way to do this?
...
Hi,
I am absolutely new to linq query, please help with this query,
dataset has fields:
Name Value Client_owner.
I want to select Value if name == "searchtext"
DataTable results = (from d in ((DataSet)_MyDataset).Tables["Records"].AsEnumerable()
orderby d.Field<string>("Name") ascending
...
Here's the c# code that I have:
private double get806Fees (Loan loan)
{
Loan.Fee.Items class806;
foreach (Loan.Fee.Item currentFee in loan.Item.Fees)
{
if (currentFee.Classification == 806) class806.Add(currentFee);
}
// then down here I will return the sum of all items in class806
}
Can I do this using li...
Why do we use index in "where clause"? Is it an auto generated number ans starts
from zero? Simple example would be really helpful.
var query =... Where((p,index)..)
...
What is the use of IQueryable in the context of Linq.Is it used for developing extension methods or any other purpose?
...
var adminCov = db.SearchAgg_AdminCovs.SingleOrDefault(l => l.AdminCovGuid == covSourceGuid);
adminCov keeps coming back null. When I run SQL profiler, I can see the generated linq, when I past that into management Studio, I get the result I expect.
LinqToSql generates this:
exec sp_executesql N'SELECT [t0].[AdminCovGuid], [t0].[Admin...
Does anyone know how to write this
var q = from c in customers
join o in orders on c.Key equals o.Key
select new {c.Name, o.OrderNumber};
In this syntax style?
var 1= customers.
.join(???)
.select(???)
I've been googling for a way to do this for days now with now luck. Everyone preferes the first syntax f...
This is also one of the interview question i have faced recently.
Description :
The task is $ 100(Please consider some currency) will be given to me.I need to purchase three items itemA,itemB,itemC.The cost of (I am not sure 0.25$ or 0.75 $ are meaningful,so think it as other currency) itemA=0.25$,itemB=0.75$ and itemC=20$. I need to p...
I've got a LINQ problem thats got me a little stumped. I can see plenty of alternative ways to find a solution but would like to try to solve the problem cos its bugging me!
public enum AnimalType {
Cat,
Dog,
Rodent
}
var orderedAnimalTypes = new [] { AnimalType.Rodent, AnimalType.Cat };
I have a function GetAnimals(Anima...
Hi.
I'm using LINQ to SQL. I wanna create a database with LINQ but the following exception has occurred :
Illegal characters in path.
This is my code :
public static string DBFolder = Application.StartupPath + "\\SQL\\";
private void MainForm_Load(object sender, EventArgs e)
{
if (!Directory.Exists(StaticVariables.DBFolder)...
I'm using stored procedure in LINQ, i know it will generate a class T(procedure name + "Result") for me automatically to store the data.
If the name of stored procedure is spCampus, the generated class will be spCampusResult.
My Question:
when i'm using SP should i create custom class that replicate all the properties ( i'm refering t...
While exploring a recent Linq question i noticed that the algorithm seemed rather slow. Digging deeper i noticed that it wasn't the linq code but the output of the result afterwards that took the long time. (Kudos to Marc Gravel btw for kicking the slickest Linq i've seen yet.)
Code:
DateTime dt = DateTime.Now;
Console....
How can i get the occurrences count of a Word in a database text field With LINQ ?
Keyword token sample : ASP.NET
EDIT 4 :
Database Records :
Record 1 : [TextField] = "Blah blah blah ASP.NET bli bli bli ASP.NET blu ASP.NET yop yop ASP.NET"
Record 2 : [TextField] = "Blah blah blah bli bli bli blu ASP.NET yop yop ASP.NET"
Record 3 : ...
Can someone tell me why this program doesn't enumerate any items? Does it have something to do with the RDF namespace?
using System;
using System.Xml.Linq;
using System.Xml.XPath;
class Program
{
static void Main(string[] args)
{
var doc = XDocument.Load("http://seattle.craigslist.org/sof/index.rss");
foreach (...
Hi,
I am developing an early version of my site and before I create the production version, I'd like people's opinions on whether I'm going about things the right way. The main objective is to allow users to share playlists. I have the User table (ASP.NET Membership), Playlist table and a permission table. I'd like a user to create a...
Just to make sure, say that i have this code:
this.allObjects = [some linq query];
and have two methods that both read (not modify) this IEnumerable, are they safe to call in parallel? Just looping through a IEnumerable should be safe right?
...
When attemptiing to solve the below assignment :
Using the Arithmetic operators ( +,-,*,/) rearrange four fives to equal the number 1 to 10.
Example : 5/5+5-5 =1 ,5/5+5/5=2
I tried in C# without using Linq (I don't know how to proceed further)
public void GetDetails()
{
char[] sym = new char[] { '+', '-', '/', '*' };
...
I want to remove duplicates from my DataTable so I'm using DataTable.AsEnumerable().Distinct(DataRowComparer.Default) but it doesn't do what I need. I think because each duplicate row has it's unique primary key column.
How can I do what I need? Write my own DataRowComparer? I don't want - because the default must works.
...