My question is regarding a code sample from this MSDN article:
Getting Started (LINQ to SQL)
The following code is listed in the article:
// Northwnd inherits from System.Data.Linq.DataContext.
Northwnd nw = new Northwnd(@"northwnd.mdf");
var companyNameQuery =
from cust in nw.Customers
where cust.City == "London"
select...
I'm trying to get a list of messages from the database where one of the recipients of the message matches a user. Normally, if there was only one recipient, you would have something like the following
var res = db.messages.Where(m => m.id == message_id)
.Join(db.persons, m => m.recipients, p => p.id, (m, p) => new {m, p})...
Is there a good way of requesting only specified columns from the database using LINQ? I want to be able to select only certain columns depending on arbitrary conditions from code.
...
From this code I can call bmwCars.CopyToDataTable() as I expected.
var bmwCars = from car in dataTable.AsEnumerable()
where car.Field<string>("Make").ToLower().Equals("bmw")
select car;
But when I have change some statement of code to below, I can't call CopyToDataTable(), why?
var ...
I'm using VS2008 to develop an app. Now, whenever I connect to database in Server Explorer, it shows me the report
The
Microsoft.VisualStudio.Data.Interop.IVsDataProviderManager
service could not be found.
And whenever I'm trying to Open my LINQ Datacontext in APP_CODE in Solution Explorer, it alerts a pop up msg which says
...
Hello everybody.
I am trying to learn some VB.NET for my coo-op that starts next week, and for that reason i took my portfolio web site that is on C# and just started to converting it to VB.NET to get familiar with the syntax.
I am sure my problem is simple however i have a hard time solving it.
I am trying to grab data with the linq qu...
I have to write kind of a complicated query to get some statistics for the rules in our system for each Agency we have in our database.
It looks something like this:
There will be an arbitrary number of columns (rules) and rows (agencies) for this data. For example, here there are 5 main rule columns shown, but this could just as eas...
After having worked in MVC for a few months, I'm back in a previously written WebForms 3.5 application, and I'm trying to fix up what I can with what I've learned.
Part of this is the "strongly-typed model with a partial view" concept which is incredibly awesome. By inheriting my custom "ListTemplate" control, I can then use its GetMod...
I'm working on the following LINQ query:
public void GetAuditRuleAgencyRecords(IEnumerable<Entities.AuditRule> rules)
{
using (LinqModelDataContext db = new LinqModelDataContext())
{
var auditAgencyRecords = (from ag in db.Agencies
join ara in db.AuditRuleAccounts on ag.Agency_Id equals ara.Agency...
I have a function where I get a list of ids, and I need to return the a list matching a description that is associated with the id. E.g.:
public class CodeData
{
string CodeId {get; set;}
string Description {get; set;}
}
public List<CodeData> GetCodeDescriptionList(List<string> codeIDs)
//Given the list of institution codes...
Here is the code I'm working with, I'm still a bit new to LINQ, so this is a work in progress. Specifically, I'd like to get my results from this query (about 7 columns of strings, ints, and datetime), and return them to the method that called the method containing this LINQ to SQL query. A simple code example would be super helpful.
...
I have an the following class I'm trying to create a list of with a bunch of data I have queried:
public class Agency
{
public string AgencyName { get; set; }
public int AgencyID { get; set; }
public IEnumerable<AuditRule> rules { get; set; }
}
Where "AuditRule" is:
public class AuditRule
{
public int AuditRuleID { ...
I have 2 collections, one of available features and one of user features. I would like to delete an item in the available features that contain the featurecode in the other collection but can't find the right syntax.
I've included my current code that doesn't compile (it's complaining that I can't use the "==" operator, my Linq knowled...
I thought IQueryable<T> was derrived from IEnumerable<T>, so why can't I access the results of my query like a collection of records?
public bool DoLogIn(System.String strUserName, System.String strPassword)
{
if (this.IsLoggedIn)
return false;
ASRDBDataContext ASRData = new ASRDBDataContext();
IQueryable<user> Curr...
Hi,
in early development stages the database is subject to continuous changes. I'm toying around with LinqToSQL and in most cases the Entity Model is just a 1:1 representation of the DB.
How can i keep the model up to date with the db changes?
Thanks.
...
Hi,
I'm facing the following problem:
in the controller I select the data I need and store it into the ViewData;
using (Models.SkedruleEntities ctx = new Models.SkedruleEntities())
{
ViewData["users"] = (from u in ctx.User select u);
}
In the View I try to read from the ViewData like this:
<p>
<%foreach(User user in (IEnumera...
Hi,
I would really appreciate some help on the best way forward with WPF and JSON. Is there any way to query the JSON response below using LINQ?
{
"code": "/api/status/ok",
"result": [
{
"id": "/en/exxonmobil",
"industry": "Petroleum",
"name": "Exxon Mobil",
"type": "/business/company"
},
{
...
Why linq is trying to check second expression anyway?
.Where(t => String.IsNullOrEmpty(someNullString) || t.SomeProperty >= Convert.ToDecimal(someNullstring))
What is usual workaround?
Update:
It is about LINQ to SQL, of course. It cannot translate to SQL.
...
Hello again; i try to save xml data from xml file. How can i do that? if i use below codes, XmlStream return null "throw null". How can do that?
my data:
<list>
<subscriber Type="Random">
<name>yusuf</name>
<surname>karatoprak</surname>
</subscriber>
</list>
public static XDocument GetRawsSnippetAsXDocuments()
...
I have a list of class items List<MyClass>
I have a seperate object that is of type MyClass
In my list I have an instance of this item but my where statement fails.
var home = Item.Find(23);
var item = allitems.Where(i => i == home);
item yields no results
allitems.Contains(home) also fails.
What am I doing wrong?
...