Consider this LINQ To SQL query. It's intention is to take a string[] of search terms and apply the terms to a bunch of different fields on the SQL table:
string[] searchTerms = new string[] {"hello","world","foo"};
List<Cust> = db.Custs.Where(c =>
searchTerms.Any(st => st.Equals(c.Email))
|| searchTerms.Any(st => st.Equals(c.FirstN...
Forgive me if this has been asked before; I couldn't find anything close after a few searches:
I'm trying to write an ActionFilter in MVC that will "intercept" an IQueryable and nullify all the parent-child relationships at runtime. I'm doing this because Linq does not serialize objects properly if they have parent-child relationships (...
From the XML Document
<?xml version="1.0" encoding="utf-8" ?>
<Data>
<Products>
<Product ProductId="1001" ProductName="ProductA" ProductPrice="123.45" />
<Product ProductId="1002" ProductName="ProductB" ProductPrice="100.45" />
</Products>
....
How to use "Sum" to find the sum of ProductPrice?
When i use
XDocu...
I want to get the Category based total of the following
<?xml version="1.0" encoding="utf-8" ?>
- <Data>
- <Products>
<Product ProductId="1001" ProductName="p1" category="A1"
ProductPrice="123.45" />
<Product ProductId="1002" ProductName="p2" category="B1"
ProductPrice="100.45" />
<Product ProductId="1003" ProductName="...
I ran into a bug with version 3.0.0.3 and the linq templates. The one where Update was a null object. So I downloaded the latest source for Subsonic.Core from git (merge branch from eibrahim Nov 3 2009). I built the source and am using the latest dll in my project. It has fixed the problem with running Update queries but now I have anoth...
How come List.Find (and LINQ-queries on the list as well) always return the first enum element when the list does not contain the element I am searching for?
Scenario:
My enum:
public enum TestEnum
{
EnumOne,
EnumTwo,
EnumThree
}
My test:
var TestEnum1 = TestEnum.EnumOne;
var TestEnum2 = TestEnum.EnumTwo;
var TestEnum3 ...
My database tables are as follows:
Users (UserId, Name)
Friends (UserIdFrom, UserIdTo)
I also have an ADO .NET entity data model that describes these tables.
My .NET entity data model has an entity named Users and an association for that entity called Friends that corresponds to the Friends table.
My question is that I want to get a ...
In our code we have:
public interface ILogMagazine
{
string Text { get; set; }
DateTime DateAndTime { get; set; }
string DetailMessage { get; set; }
}
SimpleDataContext: DataContext
{
public Table<ILogMagazine> LogMagaines
{
get { return GetTable<ILogMagazine>(); }
}
}
We try to:
DataContext db = new SimpleDataContext...
How can i extract key value pairs from this xml example using linq:
<foo>
<add key="key1" Value="val1"/>
<add key="key2" Value="val2"/>
<add key="key3" Value="val3"/>
<foo/>
...
I am very new to LINQ and have a class method, which when called, returns a DbDataReader object. How would I sort this dynamically using a LINQ query expression where the sort expression is provided as a string (e.g. "LastName DESC")
...
Hi,
I've created a MethodCallExpression that calls a function which returns a bool.
My problem is to convert the MethodCallExpression somehow into a BinaryExpression.
Or otherwise stated, how can i construct this expression by hand:
Expression<Func<string, bool>> exp = x => x.Contains("test");
...
Suppose I have linq expression q, then I want to add a sort to this query:
q = q.OrderBy(p => p.Total);
but for sort, there is desc/asc option for SQL, how to add it in above linq expression?
...
Im planning to write a code generator to generate UI (forms, grids, etc.). Since i'm using Linq i'm planning to read dbml file for metadata extraction purposes. I wonder if there is some Api to read the Dbml object model (database, tables, columns, asociations).
I've opened SQLMetal.exe with Red Gate's .NET Reflector, it contains a nam...
Hi
I'm creating my first linq based project. The DAL consists of LinqToSQL classes. And the logic layer is just another DLL for keeping it simple.
I wanted to know how do I pass the var object (result of select query) from Login Layer to Presentation Layer?
Should I write my own DTO layer between Login layer and Presentation Layer to ...
I'm still stuck with using arrays in XSD generated classes, as my XML schema is too complex for xsd2code, which created generics-based generated classes.
Is their any way to tell the cell number of an array when using foreach across it? Is there any way to do so in LINQ?
...
I have been using LINQ to query my POCO objects for some time, but I have not yet tried LINQ to SQL. I assume that LINQ to SQL queries are somehow converted to equivalent SQL queries and, given this, I am wondering if that affects the way LINQ to SQL queries are or should be written.
Are there any significant differences between LINQ to...
I am currently playing around with Silverlight3, C# and LinqToSQL .
I have build up a database on a SQLExpress Server with some tables for example:
Employees ( Id, Name, DepartmentId, TimeStamp )
Departments ( Id, Name, TimeStamp )
The Id fields are VarChar(50), the Name Fields are VarChar(100) and the TimeStamp fields are of type time...
Hi,
So I have managed to get this query working
List<string> listStatus = new List<string>() ;
listStatus.add("Text1");
List<string> listMerchants = new List<string>() ;
listMerchants.add("Text2");
from item in db.vw_Dropship_OrderItems
where listStatus.Contains(item.StatusCode)
&& listMerchants....
I've got two sequences:
IEnumerable<string> x = new[] { "a", "b", "c" };
IEnumerable<string> y = new[] { "a", "b", "d", "e" };
I'd like to find the common prefix of these two sequences (i.e. "a", "b"). Is there a succinct way to do this in LINQ?
Bear in mind that these aren't really IEnumerable<string>; they're IEnumerable<PathCompon...
query = Files
.Where(file => file.Fileinfo.Name.ToUpper().Contains(textBox1.Text.ToUpper()))
.Take(7).ToList();
I hate asking this question, but I am simply not having any progress! It should seem like a trivial task, but I am not having any luck.
The above query needs to do a search through a list of f...