What's the best practice in terms of setting up my DataContext for easy access in my extended LinqToSql classes?
For example, I have a "User" entity in my dbml and I want to add methods to that class like so:
Partial Public Class User
Public Function GetUser(ByVal UserID as Integer) as User
'Do Work
End Function
End...
My manager as work keeps talking about persistent objects. I'm more familiar with linq-to-sql. What is the differences between them and what is an example of persistent objects?
...
how do i change this to linq to sql?
select * from ratesSchedule as rs
inner join userdetails as ud on rs.sid = ud.sid
and rs.tabletype = 'd'
i got this far
var results = from rs in db.ratesSchedule
join ud in db.userdetails on rs.sid equals ud.sid
but i can't figure out how to add the "and rs.tabletype='d'"
...
Hi ,
i have this Database table(UserID,Name,Surname,Username,Password,Email) and table(RoleID,RoleName,Description) and table(UserID,RoleID )so i create a Login Authentication with username and password to access to the application (with Linq ToSql to store data) and it is right .
Now i wish create a role for each user but i don't kno...
Hi,
I want to translate LINQ expression tree to SQL statement and I don't want to write my own code for this.
Example:
var query = from c in Customers
where c.Country == "UK" &&
c.City == "London"
select c);
To
SELECT ... FROM Customers AS c WHERE c.Country = "UK" AND c.City = "London"
I know DataContext.Log, but I want to use:
quer...
Hello,
In LINQ to SQL, is it necessary to close the context after performing a select on the database (and of course, after consuming the data)? if I leave it open, doesn't it mean that the connection to the server is left open?
Thanks,
Lucian
...
From your experience, is LINQ to SQL appropriate as a Unit of Work? is it avoidable? should I prefer, say, NHibernate or another O/RM tool?
Thanks,
Lucian
...
I am using LINQ and am having a hard time understanding how I can make new "domain model" classes work within LINQ while querying across tables. I am using Linq to SQL, and C# in .NET 3.5.
Suppose I want an Extended Client class:
public class ExtendedClient
{
public int ID { get; set; }
public string Name { get; set; }
pu...
Hi, anyones knows how to do this?
Edit: I am trying to do >=. I correct the Title.
...
Lets say I have something called Stuff in my database, with a property called Id. From the user I get a sequence of selected Range objects (or rather I create them from their input) with the Ids they want. A stripped down version of that struct looks like this:
public struct Range<T> : IEquatable<Range<T>>, IEqualityComparer<Range<T>>
{...
Hi there!, Im having troubles right now, i cant update a table X in DBDataContext, so this is my snippet, by the way when I Update just one table it works! but when I Insert and then update, It Throw Exception ... "cant cast object from System.Int32 to System.String type"
{
using (DBDataContext db = new DBDataContext())
...
Is there a special way to declare a DateCreated column in a MS Sql Server table so that it will automatically fill it with the appropriate time-stamp when created?
Or.. do I have to provide the datetime to it when I do the query, manually?
...
Normally if I'm linking an ObjectDataSource to a GridView and I have a TemplateColumn that has an Eval in it and it's Null, I can just put a ".ToString()" it works fine. For some reason, this doesn't work the same when you're using Linq to SQL.
I originally was using XSD files for my DAL with a custom BLL. I tied it to the GridView wi...
Hi all,
i wish create a role for each user after that the user authenticate(login) to access to the application i will give some role to and save the role on the database.
I will make an example with the database "aspnet.mdf" and Linq toSql to store data but before i need know how create role in c#(WPF) and after created i wish add ro...
Does linq to sql automatically lazy load associated entities?
I would think it would but I can't find an article stating it as such.
...
I need to select the rows of a table where a column value is numeric, any Help?
EDIT: I have a varchar column and I need to select the ones that are numbers and the ones that are not.
EDIT 2: Integer.TryParse cannot be use because it cannot be translate to SQL.
...
Im getting an Exception when I try updating, Insert works perfectly.. so this is:
A first chance exception of type 'System.InvalidCastException' occurred in System.Data.Linq.dll
Another cue... is possible to insert in one table first and then update another table and finally submitchanges() all in same code-block?
I also comment InsertO...
I'm trying to create an html table for order logs for customers. A customer is defined as (I've left out a lot of stuff):
public class Customer
{
public LazyList<Order> Orders { get; set; }
}
The LazyList is set when fetching a Customer:
public Customer GetCustomer(int custID)
{
Customer c = ...
c.Orders = new LazyList<O...
I'm trying to combine the following expressions into a single expression: item => item.sub, sub => sub.key to become item => item.sub.key. I need to do this so I can create an OrderBy method which takes the item selector separately to the key selector. This can be accomplished using one of the overloads on OrderBy and providing an ICompa...
Consider this compiled linq-to-sql query:
private static Func<LINQDBDataContext, string, IQueryable<Pet>>
QueryFindByName =
CompiledQuery.Compile((
MyLinqDataContext context, string name) =>
from p in context.Pets where p.Name == name select p);
But I'm holding a private reference to context in the class already and I...