I couldn't get last articles of every writers in this statement.
List<Editor> lstEditors = dataContext.GetTable<Editor>().Where(t => t.M_Active).Select(t => t).ToList();
var lstArticles = from article in DAO.context.GetTable<Article>().ToList()
join editor in lstEditors on article.RefEditorId equals editor.EditorId
select
new
...
So I ran into a situation today where some production code was failing precisely because a method performed exactly as documented in MSDN. Shame on me for not reading the documentation. However, I'm still scratching my head as to why it behaves this way, even if "by design", since this behavior is exactly opposite what I would have exp...
I am using the VS Report Viewer control and stored procedures to print forms from a web application (in PDF and streamed to the client). These documents have between 1 to 200 pages, roughly, and process the same amount of rows. Not much.
Any data retrieval code needs to know about business rules. For instance, there are accounts, and ac...
Does LINQ2SQL make use of table indexes when executing a query?
...
Hi, Is there LINQ provider to access XAML?
...
This is not a question about using another tool. It is not a question about using different data structure. It is issue about WHY I see what I see -- please read to the end before answering. Thank you.
THE STORY
I have one single table which has one condition, the records are not deleted. Instead the record is marked as not active (the...
How can i insert a new object to anonymous array?
var v = new[]
{
new {Name = "a", Surname = "b", Age = 1},
new {Name = "b", Surname = "c", Age = 2}
};
I know first of all we set the array's limit(size).
I convert it to List. To insert a new object.
v.ToList().Add(new { Name = ...
Hi,
im trying to grasp LINQ as I understand it LINQ will be your DAL to your db which in turn creates for you automatically a class that maps out your db structure for you and then you can perform queries using that class ..
im trying to do a function that would return the result of my LINQ queries ..
all the examples i have been re...
Going backwards from SQL to LINQ2SQL is sometimes quite simple. The following statement
SELECT user FROM users WHERE lastname='jones'
translates fairly easily into
from u in users where u.lastname='jones' select u
But how do you get the following SQL generated?
SELECT user FROM users WHERE lastname IN ('jones', 'anderson')
...
public List<NDT_Equipment> GetALLRecords()
{
using (NDT_DB)
{
return (from a in NDT_DB.NDTEquipment select a);
}
}
where : NDT_DB - class instance of the autogenerated database context class
NDT_Equipment - partial class inside the database context class
what I want :
return all r...
I am just learning Linq and ran into a problem. For some validation, I am getting the last odometer reading from our database and need to compare that to the next reading. The odometer reading is an int on the incoming data and double on the database (changed to int on the dbml file).
Below is my code:
private bool IsValidOdometer(stri...
Below is some linqpad test code. When this runs it errors because the second instance of "item" has a null list of subitems as opposed to an empty list.
I want to treat both situations (null or empty list) in exactly the same way but I wondered if there was a cleaner way than just putting a null check on the list and initialising an emp...
Hey,
i am considering - in order the get a high performance application - to keep a single DataContext in the cache to perform the selects and updates to...
In order the keep the responsetimes low, i'd like to create an asynchronous update like the one i scribbled below:
public void AsyncInsert()
{
DataContext dc = new DataContext()...
I have an observable collection ie Owners and that collection has child items ie Dogs.
Now given another collection of local Dogs how can I select all the Owners where there Dogs exist in my local Dogs collection. The equality condition would be that the Dog == Dog.
...
Let's say, I have an instance of IQueryable. How can I found out by which parameters it was ordered?
Here is how OrderBy() method looks like (as a reference):
public static IOrderedQueryable<T> OrderBy<T, TKey>(
this IQueryable<T> source, Expression<Func<T, TKey>> keySelector)
{
return (IOrderedQueryable<T>)source.Provider.Crea...
I am not getting this Linq thing. I can write complex SQL queries and have written a few xpaths. I am trying to learn Linq to XML and cannot get past my first try despite poring over every terse example I can Google.
Given XML:
<Manufacturer ManufacturerName="Acme">
<Model ModelName="RobotOne">
<CommandText CommandName="MoveForward"...
Hello,
I have following schema:
Clients - ClientId
Users - UserId
Offices - OfficeId
ClientOffices - ClientId, OfficeId
UserOffices - UserId, OfficeId
Bold entities are EntityFramework Entities.
Now I need to write a function which accepts UserId and returns a list of Clients - who also belong to the offices to which user belongs.
...
I'd like a method that has the following API:
//get all users with a role of admin
var users = myRepository.GetUsers(u => u.Role == Role.Admin);
Will something like this work?
IList<User> GetUsers(Func<User, bool> predicate)
{
var users = GetAllUsers();
return users.Where(predicate).ToList(); ...
I have DropDownList displays all server present in my network
I want to populate the databse names when i changed it into another dropdown
I want a LINQ query to get this.
...
Hi,
I am trying to run the following code. But the code breaks
Dim complaints = From comp In Me.Db.Complaints _
Let varX = GetVariations().WithVariationId(If(comp.ItemPropertyXVariationId, 0)) _
Let varY = GetVariations().WithVariationId(If(comp.ItemPropertyYVariationId, 0)) _
Select New Hogia.Retail.POS.Data.Complaint(...