Why we need the new in the select statement on one of them?
var runs = from sampleDataTable in db.SampleData
from sampleInfoTable in db.SampleInfo
where sampleDataTable.SampleInfo.SampleInfoId == sampleInfoTable.SampleInfoId
select new {sampleDataTable.Timestamp, sampleDataTable.SampleDataId, sampleInf...
I am using VS2008. I have a project connect with a database and the connection string is read from App.config via ConfigurationManager. We are using L2E.
Now I added a helper project, AndeDataViewer, to have a simple UI to display data from the database for testing/verification purpose.
I don't want to create another set of Entity Data...
This is my query, how can I use string as orderby parameter?
string sortColumn="Title";
var items = (from ltem in ctxModel.Items
where ltem.ItemID == vId
orderby //something here
select ltem).Skip(PageSize * PageIndex).Take(PageSize);
UPDATE:
I can't just OrderBy the result set, because I FI...
let order= _relationContext.Orders
.Where(x => x.OrderNumber == orderNo)
.Select(x => new { x.OrderNo, x.OrderDate }).Single()
I want to try and do something like this
let order = _relationContext.Orders join _relationContext.Products
.Where(x => x.OrderNumber == orderNo && x.ProductId ...
I have a list like this:
List people
age name
1 bob
1 sam
7 fred
7 tom
8 sally
I need to do a linq query on people and get an int of the number distinct ages (3)
int distinctAges = people.SomeLinq();
how?
how?
...
Hello,
I am trying to get a "diff" of 2 xml documents and end up with a list of Elements that are different. Below is the XML, I was wondering if anyone can assist. In the case below, I want the list to contain the "file2.xml" element and the "file3.xml" element because they are both different or new than the first xml document.
Than...
I need to filter out parent by property value of child collection.
I am doing something like this:
var results = (from c in db.Customers where
c.Orders.Any(o => o.Status = (int)Status.Ordered)
select c;
It's fine but now I need to filter by 2 values, i.e. take all parent records that have any chilren records that have BOTH v...
I am seeing odd behavior with service queries! I am using MVVM pattern for a silverlight 3 app on 3.5 framework and Dataservices 1.5.
The following code eager loads correctly the parent object and the child heirarchy perfectly IF and ONLY IF I am preloading the data. But I would like to fetch a different set of the parent object (and it...
Hello everybody,
I have two tables: A & B
B {
B1: Field1,
B2: Field2,
...
}
A
{
Children: List of B,
A1: Field1,
A2: Field2,
}
I want to retrieve "A" entities with related "B" entities like this:
DataContext.A.Select( a => new MySubset( A1 = a.A1, Children = a.Children.Select(b => b.B1).ToList())...
I'm trying to create a base repository for use with Entity Framework 4.0 and having some trouble. In this code below, why is it not possible to do this in one line?
public IEnumerable<T> GetAll<T>(Expression<Func<T, bool>> filter)
{
IEnumerable<T> allCustomers = this.GetAll<T>();
IEnumerable<T> result = allCustomers.Where(filte...
I have a method and I want different users to pass me xml files. These files will have different names for the elements I am looking for and the elements I am looking for maybe at different structures. My first impression was that we should just tell them to pass in the xml in a standard format. However this is how they have their dat...
Hi,
I've managed to save ListView items to a System.Collections.Specialized.StringCollection property settings using this LINQ one liner:
My.Settings.Property1.AddRange(ListView1.Items.Cast(Of ListViewItem)().[Select](Function(a) String.Join(Convert.ToChar(Keys.Tab), a.SubItems.Cast(Of System.Windows.Forms.ListViewItem.ListViewSubItem)(...
I have a List like
"test", "bla", "something", "else"
But when I use the Aggrate on it and in the mean time call a function it seems to me that after 2 'iterations' the result of the first gets passed in?
I am using it like :
myList.Aggregate((current, next) => someMethod(current) + ", "+ someMethod(next));
and while I put a breakp...
What does var really do in the following case?
var productInfos =
from p in products
select new { p.ProductName, p.Category, Price = p.UnitPrice };
...
Calling Index view is giving me this very very annoying error . Can anybody tell me what to do about it
Error:
The model item passed into the dictionary is of type 'System.Collections.Generic.List1[MvcApplication13.Models.Groups]', but this dictionary requires a model item of type 'MvcApplication13.Helpers.PaginatedList1[MvcApplication1...
I have a LINQ query which checks to see if there are any tests done since the beginning of the year.
var MetersTestedCount = (from n in _mttDomainContext.MTTMeterTests
where n.TestDate > DateTime.Parse("1/1/2010")
select n.TestDate).Count();
This query however returns an e...
Hello,
I am trying to use the new LINQ notation to add an item into a folder.
I can add the item to the root of the list with:
dataContext.MyList.InsertOnSubmit(mynewObject);
But I can't find a way to make it go inside a folder.
I am trying to avoid instanciating SPWeb, or SPSite objects.
Thanks,
Itay,
...
In the form we have this where IntaktsBudgetsType is a poorly named enum that only specifies wether to populate the datagridview after customer or product (You do the budgeting either after product or customer)
private void UpdateGridView() {
bs = new BindingSource();
bs.DataSource = intaktsbudget.GetDataSource(this.comboBoxKun...
Hi,
maybe someone can help.
I want to have on mapped Linq-Class different Datatype.
This is working:
private System.Nullable<short> _deleted = 1;
[Column(Storage = "_deleted", Name = "deleted", DbType = "SmallInt", CanBeNull = true)]
public System.Nullable<short> deleted
{
get
{
return this._dele...
If I do
for (int i = 0; i < appSettings.Count; i++)
{
string key = appSettings.Keys[i];
euFileDictionary.Add(key, appSettings[i]);
}
It is working fine.
When I am trying the same thing using
Enumerable.Range(0, appSettings.Count).Select(i =>
{
string Key = appSettings.Keys[i];
string Value = appSettings[i];
euFileDic...