I'm using datalist in my application and i'm binding datalist with lisq to sql
dim db=new linqdatacontext();
var products=from p in db.products select p;
datalist.datasource=products;
datalist.databind();
now how can i do paging in my datalist?
...
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})...
Hi,
Using linqtosql, how would I get a colleciton of User objects, if I have an array of UserID's that I want to fetch?
...
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.
...
With linq, do you create a single dbContext per request like nHibernate requires (for performance reasons, creating sessions in nhibernate from what I understand are an expensive call).
i.e. in my asp.net-mvc application, I may for a given action, hit the database 5-10 times on seperate calls. Do I need to create a context and re-use ...
Hey,
I've got an performance issue in my application using a MSSQL DB. I have a Database Architecture with the following tables:
Job (Primary Key: Job ID)
Jobitem(Primary Key: Jobitem ID, Foreign Key: Job ID)
Job2Property (Foreign Key: Job ID <-> Property ID)
Jobitem2Property(Foreign Key: Jobitem ID <-> Property ID)
Property (Primary ...
I'm iterating over a set of instantiations of a LINQ-to-SQL class.
During this iteration, I'm making changes, flagging some for deletion and even inserting new ones in the datacontext. When I'm done iterating, I fire context.SubmitChanges() - it works, but it's amazingly slow. I'm running an express version of MSSQL 2008 locally.
Also,...
Currently, I'm developing an application that depends on (and thus connects to) various databases via LINQ-to-SQL. For one of the databases, the connection string may vary and is thus configurable - however, the schema of this database is identical for all connection strings.
Because of the configurable connection string, I want to val...
I noticed a strange behaviour in my Import Service today when I tried to import multiple data records.
When I do it like this, all data records are imported and the auto-incremented value is correct (see screenshot):
public void Create(List<Property> properties)
{
foreach (Property prop in properties) {
dbc.Property.InsertOnSu...
I have the following code:
List<T> list = new List<T>();
IEnumerable<T> query1 = ...
IEnumerable<T> query2 = ...
IEnumerable<T> query3 = ...
list.AddRange(query1.ToList<T>());
list.AddRange(query2.ToList<T>());
list.AddRange(query3.ToList<T>());
As far as I'm aware this will cause a trip to the database each time the ToList method i...
Table like
datetime a1 b1 x2 ...
07-01-2009 13:10 8 9 10
07-01-2009 13:11 8 8 2
07-01-2009 13:12 9 1 1
1 row per second for a whole day (=86400 rows); ~40 columns; all same format
I'm looking for a way to retrieve a max value and the time for a column to specify.
I'm looking for a way to...
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 would like to enable users of my application to define a number of (say) email addresses. Then I would like to give them the ability to rearrange these addresses, so the primary address is on top, secondary next, etc.
Let's suppose I have a UserEmailAddresses table in a database that links a user (UserId) and an email address (Email...
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 { ...
How can I force LinqToSql DataContext to consider a property dirty and submit it to the database?
in my case the property is XElement, which gets modified, but DataContext doesn't catch it, since the actual reference stays the same.
I guess I could try to assign property null or new XElement and then assign it back to the original XEle...
Is it possible to do a partial update through linq2sql?
If I want to update only 2 fields I would use sql like
update table set col1 = val1, col2 = val2 where id = @id
I find the "fetch it from database, change it and then update" process a bit, well ineffective, if not just weird.
...
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.
...