C#, .net 3.5
I am trying to create a base class that has a generic method. Classes that inherit from it should specify the method's type(s).
The premise for this is for creating classes that manage filtering.
So I have:
public abstract class FilterBase {
//NEED Help Declaring the Generic method for GetFilter
//public abstrac...
I have an IEnumerable<string> which I would like to split into groups of three so if my input had 6 items i would get a IEnumerable<IEnumerable<string>> returned with two items each of which would contain an IEnumerable<string> which my string contents in it.
I am looking for how to do this with Linq rather than a simple for loop
Thank...
An Activity occurs at a location on a specific date, but each activity may be repeated at the same or different locations on different dates. I have created an entity framework model, and wish to populate it with relevant Activities which occur between two dates, ordered by the locations distance from a specified location.
I therefore ...
For the fun of it, I would like to see someone use and abuse LINQ to solve this money problem.
I really have no idea how you would do it - I suppose Populating some set and then selecting off of it.
If given a total number of coins and give the total amount of all coins added together:
Show every possible combination of coins. Coins are...
Hi,
Appreciate if I can get some help writing a LINQ that will get ALL FIELDS from table A, and those fields for which profile 1 has a value in table AB, show the value, otherwise if profile 1 has no entry in table AB, then show value as null.
Table A
AID Field
-----------
1 OneField
2 TwoField
3 ThreeField
Table ...
Hi,
I have the following LINQ query:
var aKeyword = "ACT";
var results = from a in db.Activities
where a.Keywords.Split(',').Contains(aKeyword) == true
select a;
Keywords is a comma delimited field.
Everytime I run this query I get the following error:
"LINQ to Entities does not recognize the method 'Boo...
I am using Linq and the Entity Framework. I have a Page Entity, that has a many-to-many relationship to a Tag Entity.
I want to create a Linq query that pulls all pages that match all of the supplied Tags (in the form of a Int64[]).
I have tried various WhereIn, and BuildContainsExpression examples, but none are working as expected.
...
I use LINQ to query my MSSQL 2005 database. I want to show several fields of some tables in one DataGridView. The selection of a row of the DataGridView should result in showing results in another DataGridView based on a column which is not shown in any DataGridView (it is an ID attribute).
What is a good way to accomplish this?
My I...
following sql query is working and gets the visits per day for the current month
select date(date) as DayDate, count(*) As visitsaday from Visits group by DayDate having DayDate between date('now','start of month') and date('now','start of month','+1 month','-1 day')
For days I try to figure out how to get this running with the entit...
First let me start by saying that I don't have a complete understanding of Linq. I am trying to dynamically query a database, The first query uses LINQ-SQL which works fine, but the second dynamic call is what fails in run time
public void getTables()
{
foreach (var c in dc.GetTable<TableListing>())
{
Li...
Hi, I am new to LINQ, so I am pretty confused here. I have a database and try to run following code.
IQueryable<decimal> location_ids = (from m in _db.Admins
where m.UserId.Equals("c5d3dc0e-81e6-4d6b-a9c3-faa802e10b7d")
select m.LocationId);
if (!location_ids.Contai...
Hi, I have a table Admins, which creates a relationship between Users and Locations:
ID - numeric (PK)
UserId - uniqueidentifier (FK to UserId in aspnet_Users table)
LocationId - numeric
Now I want to execute command:
IQueryable<decimal> location_ids = (from m in _db.Admins
where m.UserId.Equals( n...
WIth Ria Service, I have a linq query like:
EntityQuery<Employee> query = from e in ctx.GetEmployeeQuery()
orderby e.DateCreated descending
select e;
Then I want to get the top 100 records from this query, like SQL
select top 100 * from Employee
How to write the linq query?
...
I issued a SQL on SQL Server 2000:
select * from Employee where LastUpdateDate >=DateAdd(yyyy,-1,Getdate())
It works fine and got some records.
Then I write a Linq for the same purpose:
EntityQuery<Employee> query = from e in ctx.GetEmployeeQuery()
where e.DateCreated >= DateTime.Today.AddYears(-1)
b...
How to write (simple) LINQ to Entities query that groups elements by some attribut and count them?
SELECT answernumber, count(answerID) FROM answers
WHERE questionID = id
GROUB BY answernumber
ORDERBY answernumber;
That should be simple but i don't know how to write it.
...
I asked a question here about an Linq error that results from mixing Linq-To-SQL with C# code. In brief, the compiler gets confused and doesn't realize that you are intending to call a local function on the resultset after it's come back from the database.
The answer I accepted was to use AsEnumerable() on the result set, thus forcing ...
Suppose I have following tables with the right relationships built:
Employee(empID, ...)
Address(AddresID, ...)
EmployeeAddress(EmpID, AddressID, ...)
Then modified the generated code for GetEmployee by .NET RIA Services like:
public IQueryable<Employee> GetEmployee()
{
var Employee = this.Context.Employee.Include("Employ...
How to get an average time from an Datetime field via the Entity Framework ?
How to subtract one Date from another ?
I am thinking of something like:
ObjectQuery<Visit> visits = myentitys.Visits;
var uQuery =
from visit in visits
group visit by visit.ArrivalTime.Value.Day into g
select ...
I have two objects and I want to merge them:
public class Foo
{
public string Name { get; set; }
}
public class Bar
{
public Guid Id { get; set; }
public string Property1 { get; set; }
public string Property2 { get; set; }
public string Property3 { get; set; }
public string Property4 { get; set; }
}
To create:...
The question is related to financial products, interest rates and two properties that determine which interest a certain product has. But I think fruits and baskets are easier to visualize for this.
First, we have fruit. Fruit can have a specific size (Small, medium, Large) and colour (Red, Green, Blue). These will be two different enum...