hi, I have a table "Information" in my dataBase(SQL), it has 3 fields : ID , Date , Description
I want to show this data in a gridview between date1 and date2, but I want to show an empty record for date3 if date3 is between date1 and date2 but there is no data in my table that Date = date3, how can i do this with C# and Linq?
...
I am trying to build a simple search against some entities (EF4, if that makes any difference). Passed into my search query is a list of criteria objects. The crieteria object looks like this:
public class ClaimSearchCirtieria
{
public Guid? FinancialYear { get; set; }
public bool AllClaimants { get; set; }
public IList<Guid...
Hi All
I have a list of objects, which has a method that has a couple of out parameters. How do i call this method on each object, get the out parameter values and use them later on in the query, perhaps for checking in a where clause?
Is this possible and if so can someone please demonostrate through sample code.
Thanks!
...
We (my team) are about to start development of a mission critical project, one of the sub-systems of this project is a Windows service. This service will be a backbone of the entire system and has to respond as per mission critical standard.
This service will contain many lists to minimize database interaction and to gain performance, ...
I'm using IEnumerable orderby to sort my items in ascending format but it does not work my query is like this:
IEnumerable<Step> steps = allsteps.Where(step => step.X <= Y);
steps = steps.OrderBy(step => step.X);
its not deffer to use OrderBy or OrderByDescending
why?
I'm want to use Sum() method to sum some items and item orders i...
I have a database that deconstructs an x,y coordinate pair table into specific dataitems.
Coordinate
{
int X,
int Y,
int Value
}
How do I rejoin these coordinates in Linq into a table? What if there are empty spaces in the Database (denoted by -):
Y
0 1 2
-------
0 | 4 6 7
X 1 |...
How would you suggest using AsEnumerable on a non-generic IQueryable?
I cannot use the Cast<T> or OfType<T> methods to get an IQueryable<object> before calling AsEnumerable, since these methods have their own explicit translation by the underlying IQueryProvider and will break the query translation if I use them with a non-mapped entity...
I've got what I think is a working left outer join linq query but I'm having problems with the select because of null values in the right hand side of the join. Here is what I have so far
Dim Os = From e In oExcel
Group Join c In oClassIndexS On c.tClassCode Equals Mid(e.ClassCode, 1, 4)
Into right1 = Group _
F...
I have a table in a DB that stores a Data Value and a two tiered label.
Data
{
int ID,
string Label,
string Section,
double Value
}
An example entry, to illustrate my problem:
{"Sport", "", 12}
{"Sport", "Baseball", 33}
{"Sport", "Football", 44}
{"Food", "", 34}
{"Food", "Pizza", 56}
{"Food", "Donuts", 19}
I'd ...
I have a class that contains player numbers...
public class Game {
public int blackPlayer { get; set; }
public int whitePlayer { get; set; }
}
and a...
List<Game> games;
I want to know which player number occurs the most in the list (regardless if they played as black or white). Does anyone know a good LINQ expression this?...
Is this the best way to select the Fruit object I need from the ID?
So I'm taking the ID and returning its name, id being unique, so there will only ever be one result.
If I don't use .Single() I get IQueryable but I just want the single object
var fruitName = (from p in fruitDB.Fruits
where p.FruitID ==...
Is there anyway to join LINQ where clauses as OR ?
var ints = new [] { 1, 3, 5, 7 };
var query = from i in ints select i;
query = query.Where (q => q == 3);
query = query..Where (q => q == 7);
What I want is the ability to dynamically add where clauses but make them use OR instead of AND
...
Since we can:
Expression<Func<int, bool>> predicate = x => x > 5;
var result = Enumerable.Range(0,10).Where(predicate.Compile());
How can I:
Func<int,bool> predicate = x => x > 5;
Expression<Func<int,bool>> exp = predicate.Decompile();
That is, I want to get the corresponding Expression of the Func. Is it possible?
...
Hi all,
I have a query in the form:
var fruits = (from p in fruitDB
where (p.Fruit.FruitID == fruitID && p.Color.ColorID != null )
select p.Color).Distinct();
VS 2010 gives me a blue underline and informs me "Expression is always true". Now granted I agree if the data in the database wasn't stuffed up, but...
I'm having a List<string> like:
List<String> list = new List<String>{"6","1","2","4","6","5","1"};`
I need to get the duplicate items in the list into a new list. Now i'm using nested for loop to do this.
The Resulting list will contain {"6","1"}
Is there any idea to do this using LINQ or Lambda expression?
...
Hi,
I have 2 IEnumerable<XPathNavigator> and I want to sort it by child value.
item1 = from XPathNavigator item in iterator1 select item;
item2 = from XPathNavigator item in iterator2 select item;
item1 = item1.Union(item2);
item1.OrderBy(res => int.Parse(GetNavigatorValue(res, "./item[@value='ParentId']")));
static string GetNavi...
I use ADO.NET Entity Framework with several data access layer methods that return the same domain entity. Let it be:
class PersonEntity {
public int Id { get; set; }
public string Name { get; set; }
}
and methods return Person entity by different criteria:
PersonEntity GetById(int id) {
return db.Person.FirstOrDefault(x => new ...
I'm having an xml file like
<Root>
<Child val1="1" val2="2"/>
<Child val1="1" val2="3"/>
<Child val1="2" val2="4"/>
</Root>
i need to display the data from the Xml file to a Listview like
(Added A to index value)
Now i'm using like
1.Stores the data in an XmlNodesList
2.Then iterate through the nodeslist and add the attribut...
Hello,
This is mysql query:
SELECT count(PVersion), PVersion
FROM [Products].[dbo].[Active_Details]
group by PVersion
order by count(PVersion);
What will be its LINQ to SQL.
...
Let's say I have a linq query like the one below
var LinqResult =
from a in Db.Table
select new {Table = a};
From here, how can I grab a specific row from these results and put it on top?
...