I've been trying to solve a little problem with VB.NET and the expression trees it likes to generate.
I have a simple test...
Public Sub ActiveRecord_Find_By_NonKey_Returns_123()
Dim orders = Order.Find(Function(item As Order) item.EmployeeID = 1)
Assert.Equal(Of Integer)(123, orders.Count)
End Sub
One would expect that to wor...
I'm considering using LINQ-to-SQL for creating the DAL in my app. I normally create the DAL manually as I'm not a big fan of ORM (too much abstraction IMO) but I'm trying to save some time for an impatient client.
My question is, how do you map the classes generated by LINQ-to-SQL to your BLL classes? Do you just add your code to the cl...
I'm looking at standardizing programming in an organisaiton. Half uses stored procedures and the other half Linq. From what i've read there is still some debate going on on this topic.
My concern is that MS is trying to slip in it's own proprietry query language 'linq' to make SQL redundant.
If a few years back microsoft had tried to...
Let's say I have a DB table with columns A and B and I've used the Visual Studio designer to create a Linq objects for this table. All fields are marked NOT NULL.
Now I'm trying to edit this record using typical MVC form editing and model binding, but field B doesn't need to be editable, so I don't include it in the form.
When the pos...
I want to include a table (Events) from another database in my LINQ to SQL class.
How should I format the Data Source of that table?
I have tried with IP.dbo.Events, IP.DatabaseName.dbo.Events and so on, but can not get it to work.
The reason for all this is to select Events that a Client have attended.
I have also tried to have the ...
I am trying to get to grips with the Entity framework, and have a requirement to order results by distance from a point on the globe. I have decided on previous advice to do this using a stored procedure which I have successfully done populating a view. However I need to return multiple tables, which I understand I cannot do directly usi...
I end up writing a lot of code that looks like
var ordered = isDescending ? queryable.OrderByDescending(x => x.ID) : queryable.OrderBy(x => x.ID)
but with different expressions such as x => x.DateOfBirth etc. What I would like to do is place that in a generic extension method that I could parse my expression, and a boolean isDescendin...
I have a Linq query that will search a column for a word and return the number of entries found with the said word. I then loop this for each word I'm looking for.
var results = new List<WordCountResult>(words.Count);
foreach (var word in words)
{
var wordCount = (from s in _searchResult
where s.Date>= startD...
for instance a very simple method:
private int GetCount(ITable table) {
return (from T in table select T).Count();
}
...
Hello all,
I am using c#.net and LINQ
Within my LINQ model I have three database tables:
The code below is how I access the data:
public IQueryable<tblAvailability> GetAvailabilitiesBySet(int id)
{
return (from a in dc.tblAvailabilities
where a.asID == id
select a).DefaultIfEmpty();
...
This LINQ query expression emits a left join and works:
from p in Prices
join ip in ItemPrices
on new { p.PriceId, ItemId = 7 } equals
new { ip.PriceId, ip.ItemId }
into priceItemPrice
from pip in priceItemPrice.DefaultIfEmpty()
select new
{
pricesPriceId = p.PriceId,
z = (int?)pip.PriceId,
p.Content,
p.Pri...
LINQ Groupby query creates a new group for each unique key. I would like to combine multiple groups into a single group based on the key value.
e.g.
var customersData = new[]
{
new { id = 1, company = "ABC" },
new { id = 2, company = "AAA" },
new { id = 3, company = "ABCD" },
new { id = 4, company = "XYZ" },
new {...
I am using SubSonic3 with SQL Server 2000.
I have problem with the method "FirstOrDefault" - it always throws an exception = "Line 1: Incorrect syntax near '('." from the SubSonic.Linq dll
EDIT (Added code from comment):
InventoryDAL = DAL project name (dll)
Inventort= Subsonic3 Gnerated classes
Name space WHWarehouses = gnerated ob...
I am trying to get top countries list froma list of ips in my database, With sql query i return a data table consist of data like below
IP IpCount
+++++++++++++++++++
XXX.XXX.XX1 20
XXX.XXX.XX2 1
XXX.XXX.XX3 2
On data bind to a repeater control im using Maxmind Ip to Country db to get country name
Utils.GetCo...
What are the current options for querying and joining two different Entity Data Models? I've seen that it's possible to share a single model schema between multiple mapping and storage schemas, but it seems clunky and not encouraged. The other option I can think of is to query the entities separately and then join the linq objects, but I...
How do I embed the ordinal number of element as its attribute in this linq query.
var AllSections = from s in xmlDoc.Descendants("section")
select new
{
id = s.Attribute("id").Value,
themeTitle = s.Element("themeTitle").Value,
...
Consider a class that's used to represent the results of a GroupBy(). The goal of the code is to replace a stored procedure that would have grouped and counted a bunch of rows by the Created datetime field.
public class Statistic
{
public int NumRecords { get; set; }
public DateTime Date { get; set; }
}
Here's the code raisin...
I have a entity Person. at server side, take EF as DAL. then I extend this entity by adding a read only member:
[DataMember]
public decimal AccountBalance
{
get
{
using (MyEntities ctx = new MyEntities())
{
return 123.45M;
}
}
}
Client side get the date by ria service by
public IQueryable<Pers...
Is there an application or utility that will convert LINQ to Lambda Expressions? (or an add-on to LINQPad)
...
The MSDN explains Lookup like this:
A Lookup<TKey, TElement>
resembles a Dictionary<TKey,
TValue>. The difference is that a
Dictionary<TKey, TValue> maps keys to single values, whereas a
Lookup<TKey, TElement> maps keys to collections of values.
I don't find that explanation particularly helpful. What is Lookup used for?
...