I have an enum(below) that I want to be able to use a LINQ extension method on.
enum Suit{
Hearts = 0,
Diamonds = 1,
Clubs = 2,
Spades = 3
}
Enum.GetValues(...) is of return type System.Array, but I can't seem to get access to a ToList() extension or anything else of that sort.
I'm just looking to write something like...
I have a List with the numbers (5,9,3) in it. Let's call it MyList
I would like to perform
var results = from a in myEntities.thing1 where a.ID belongsto MyList select a;
right now I do
List<T> t = new List<T>(); //I actually define T to a strong type
foreach (int i in MyList)
{
t.add(from a in myEntities.thing1 where a.ID==i sele...
We have several classes with multiple 1:1 Relationships for quick joins, and while this works fine for anonymous types for tabular display, I'm unsure how to fully populate the type in a single linq query.
We have these properties either because it's an off 1:1, or we don't want to query through a child collection to find a "primary" ev...
Hello,
I have a simple Linq query below:
var seq = (from n in GetObjects()
select n.SomeKey)
.Distinct()
.Count();
This query works find with SQL Server 2005 and above.
But, this start to give headache when I hooked the EF to SQL Server 2000. Because EF is using APPLY operator which only SQL Server 200...
Have a look at the following tests:
[TestMethod]
public void CanRead()
{
using (ISession session = OpenSession())
{
var criteria = session.CreateCriteria(typeof(Action));
var result = criteria.List<Action>();
Assert.IsTrue(result.Count > 0);
}
}
[TestMethod]
public void CanReadWithLinq()
{
using (ISession...
Hi All,
I have a generic dictonary which is templated in the following manner:
Dictionary<object, IList<ISomeInterface>> dictionary1 = new Dictionary<object, IList<ISomeInterface>>();
If I wanted to omit certain list items against arbitrary keys (that is the items that are in the list contained within the value part of each of t...
I want to get a collection of Product entities where the product.Description property contains any of the words in a string array.
It would look something like this (result would be any product which had the word "mustard OR "pickles" OR "relish" in the Description text):
Dim products As List(Of ProductEntity) = New ProductRepository(...
When one is using ADO.NET Data Services and consuming it via the Linq to REST (formerly Project Astoria), it doesn't seem to be as intuitive as it could be.
Namely, with normal Linq to SQL, the DataContext monitors objects and tracks changes, so a simple SubmitChanges() call will actually submit all my changes.
But with Linq to REST, I...
I have a stored procedure that uses a view to pull 6 averages. The SQL database is SQL Server 2000. When I run it in the Query analyzer, it takes roughly 9 seconds. What can I do to get better performance? Should I return the rows using LINQ and determine an average that way? Will it be faster?
Here's an example of my current sproc:
cr...
Having two lists of same object type. I want to join them using an interleave pattern where i items of the first list are separated by j items from the second list.
In essence:
First list
{a, b, c, d, e, f, g, h}
Second list
{0, 1, 2, 3, 4}
where the grouping count for the first list is 3 and for the second list is 2.
...
This is my query:
var query = (from v in _dataContext.UserInterests
join u in _dataContext.Users on v.UserId equals u.UserId
where u.Email.Equals(EmailAddress)
select v);
foreach (UserInterest reg in query)
{
reg.Promotion = "1234-24323-1212";
...
Hello, I am a front end developer working on a small social network. Currently, we are using SubSonic and it has satisfied all of our needs. Since Microsft has stopped supporting LINQ, I want to know how this will affect the development of SubSonic if at all. Is there any reason to move to ADO.net?
...
I use linq to nhibernate and the IQueryable.Where function in an application I'm building. And what mystifies me is how do the Expressions I create and pass to the Where function of a INhibernateQueryable affect performance.
I'm not really sure what are the gotchas I should avoid in writing these query Expressions, in terms of perfor...
Dim Cozinhas as string = "1, 2, 3"
Dim FiltroCozinha() As String = Cozinhas.Split(",")
Dim Empresas = (From E In lstEmpresas _
Group Join CE In lstCozinhasEmpresas On CE.EmpresaID Equals E.EmpresaID Into CEJ = Group From CE In CEJ.DefaultIfEmpty() _
Group Join FC In lstFiltroCozinha On FC Equals CE.Cozinh...
My application is structured as:
namespace DomainModel.Abstract
{
public interface IContentItemsRepository
{
IQueryable<Content> ContentItems { get; }
IQueryable<Category> Categories { get; }
IQueryable<ContentCategory> ContentCategories { get; }
}
}
namespace DomainModel.Entities
{
[Table(Name ...
Hi,
I have a scenario where I need to search for cars by keywords using a single search field. The keywords can relate to any of the car's attributes for e.g. the make or the model or the body style. In the database there is a table named 'Car' with foreign keys referencing tables that represent models or makes or body style.
What woul...
How can I get data from these related entities. I want to get these columns only:
Term.Name , related Concept_Term.Weight, related Concept.Id
I wrote the SQL but I don't want to use
select t.Name,ct.ConceptId,ct.Weight from Term t
inner join Concept_Term ct on t.Id=ct.TermId
inner join Concept c on c.Id=ct.ConceptId
where...
From the given string
(i.e)
string str = "dry sky one two try";
var nonVowels = str.Split(' ').Where(x => !x.Contains("aeiou")); (not working).
How can i extract non-vowel words?
...
public ActionResult myItems() {
var dataContext = new RecordsDataContext();
MembershipUser myObject = Membership.GetUser();
string CurrentUserName = myObject.UserName.ToString();
var user = from i in dataContext.myUsers
where i.userName ==CurrentUserName
...
Just wanted to check to see if there's a more elegant way to accomplish this task using Linq. I'm greatly simplifying the code for brevity. I'll go into my reasons in a minute, but it goes like this:
(from t in doc.Descendants(p + "Task")
where t.Element(p + "Name") != null
select new {
FirstName = t.FirstName,
LastName = t....