I'm trying to check if a date is null in linq and if it isn't check its a future date.
QuestionnaireRepo.FindAll(q => !q.ExpiredDate.HasValue || q.ExpiredDate >DateTime.Now).OrderByDescending(order => order.CreatedDate);
I need the second check to only apply if the first is true. I am using a single repository pattern and FindAll acce...
When using this code (simplified for asking):
var rows1 = (from t1 in db.TABLE1
where (t1.COLUMN_A == 1)
select new { t1.COLUMN_B, t1.COLUMN_C });
var rows2 = (from t2 in db.TABLE2
where (rows1.Contains(t2.COLUMN_A))
select t2;
I got the following error:
The type arguments for method
'System.Linq.Enumerable.Cont...
Ok everyone, I must be missing something here.
Every LINQ example I have seen for VB.NET anonymous types claims I can do something like this:
Dim Info As EnumerableRowCollection = pDataSet.Tables(0).AsEnumerable
Dim Infos = From a In Info _
Select New With {.Prop1 = a("P...
I'm trying to find a solution to the following (I'm thinking with Linq) to the following:
I need to pull down certain files from a larger list of files on an ftp server that have a similar file name. For example, we send an order file to some company for processing then they return a response file that we can download.
So, I could sen...
I have a list (that comes to my middleware app from the client) that I need to put in my database. Some items in the list may already be in the db (just need an update). Others are new inserts.
This turns out to be much harder than I thought I would be. Here is my code to do that. I am hoping there is a better way:
public void Inse...
I am writing the following in LINQ
Enumerable.Range(50, 100).Select(n => n/10 == 1)
but it's not working. How to write the above query?
...
Let's say I have an object graph of Countries / States / Cities, like below:
public class City
{
public string Name { get; set; }
}
public class State
{
public List<City> Cities { get; set; }
}
public class Country
{
public List<State> States { get; set; }
}
Is there a simple way to query a List<Country> to get all the c...
the ToSelectList method I have:
public static IList<SelectListItem> ToSelectList<T>(this IEnumerable<T> itemsToMap, Func<T, string> textProperty, Func<T, string> valueProperty, Predicate<T> isSelected)
{
var result = new List<SelectListItem>();
foreach (var item in itemsToMap)
{
result.Add(new SelectListItem
...
Anyone know why only undirectional serialization is supported in the Linq designer?
Consider the following example:
Say we have a Customer who requested an Order containing Products. We set the Serialization Mode in the Linq designer to Unidirectional to enable serialization.
When looking at the code for the Order object, the DataMem...
Hi...
I'm trying to bind a selected user's role to a dropdown-list.
The purpose of this is to be able to change said user's role.
I'm attempting this inside a formview hooked up to a linqdatasource which contains a row from the aspnet_User table.
The dropdown list is hooked up to a linqdatasource of all the roles in the aspnet_Roles ...
I use LINQ-SQL as my DAL, I then have a project called DB which acts as my BLL. Various applications then access the BLL to read / write data from the SQL Database.
I have these methods in my BLL for one particular table:
public IEnumerable<SystemSalesTaxList> Get_SystemSalesTaxList()
{
return from s in db.SystemSalesTa...
here is a code :
using System;
using Nemerle.Collections;
using Nemerle.Text;
//using Nemerle.Utility;
using System.Linq;
using Nemerle.Data.Linq;
using NUnit.Framework;
using System.Data.Linq;
namespace LinqTestes
{
[TestFixture]
public class Linq2SqlTests
{
static ReadConnectionString() : string
{
def currAssm = ...
Hi,
I have a table like below:
EmployeeId
EmployeeName
RequestId
RequestName
EmployeeId
RequestId
I need to a to assign requests in a sequential fashion(those who has mininum number of requests).
Can I know how to get employee who has minimum requests using linq???
Thanks,
Mahesh
...
Hi,
I can't quite figure out why this Linq Statement isn't working as i would expect:
Dim distinctSurchargesList = (From thisparent As Parent In ThisParentCollection _
From thisChild As Child In thisparent.theseChildren _
Select New With {.childId = thischild....
I can't use TryGetValue() from dictionary in linq expression with anonymous type.
Dictionary<string, string> dict = new Dictionary<string, string>()
{
{"1", "one"},
{"2", "two"},
{"3", "three"}
};
public string getValueByKey(string value)
{
string sColumnType = "";
dict.TryGetValue(value, out...
Given a datasource like that:
var c = new Car[]
{
new Car{ Color="Blue", Price=28000},
new Car{ Color="Red", Price=54000},
new Car{ Color="Pink", Price=9999},
// ..
};
How can I find the index of the first car satisfying a certain condition with LINQ?
EDIT:
I could think of something like this but it looks horrible:
int fir...
Good Morning All,
I'm trying to use "Contains" to see if an object is within the collection. When I break I can see that the object is indeed part of the collection however "Contains" seems to be returning false indicating the item is not in the collection. Any idea what I'm doing wrong?
if(HttpContext.Current.Session["AutoPayTypes"] !...
Hey,
I have googled this a little and didn't really find the answer I needed.
I am working on a webpage in C# with SQL Server and LINQ for a customer.
I want the users to be able to send messages to each other. So what I do is that I unit test this with data that actually goes into the database.
The problem is that I now depend on ha...
I have a repeater using a LinqDataSource as a data source. When a query string is entered, I'd like to filter the results, but ONLY when a query string is entered. If there is no query string, the results should not be filtered, all results should be returned.
I'm trying to add a WhereParameter to my LinqDataSource in the Selecting even...
My OM has a 'product' object.
Each product has a 'manufacturer id' (property, integer).
When I have a list of products to display, the first three are displayed as the 'featured products'.
The list is already sorted in a specific sort order, putting the 'featured' products first in the list.
However, I now need to ensure the featured...