I'm trying to write a Linq query which fetches all users whose first or last name begins with at least one string in a list of strings. This is used for auto-completion of recipients in a messaging system.
This was my first naive attempt:
var users = UserRepository.ALL()
foreach (var part in new [] { 'Ha', 'Ho', 'He' })
{
string pa...
Good afternoon,
I am trying to use as Linq to SQL datacontext for a ListBox in WPF.
Basically, I assign the Linq DataContext to the form's DataContext property. Then, I bind it to the list.ItemsSource.
Everything works fine, I can show the details of each of my elements in a textbox (master-details scheme).
The thing is, I would like...
I have a database called
"Config" where I have a table called "Customer"
In the Customer table I hold the login credentials, along with a connection String to the client's database.
Inside of my controller I'm checking to see what customer database i'm querying
String connectionString = "";
if (id == 1)
conn...
Is it possible to configure Linq to SQL to update a column as getutcdate() (ie. obtain the date from the db server, rather than the web server), or is a trigger my only option?
I have tried setting the Time Stamp property on the model, but that did not help.
Any thoughts?
...
Will there be a problem of having datacontext object in a shared variable for a website (instead of instantiating it again and again). What I mean is, is the db connection opened for ever as long as datacontext is in memory?
Will there be a performance hit if I instantiate it everytime I need.
How about the same case for context objec...
Hi,
In my project I create the Linqto-SQL Classes using SqlMetal. The problem with this is that SqlMetal doesnt appear to create a parameterless constructor. I've always got round this because in my code I can always get the default connectionstring name and pass it to the constructor, however now I am being forced to use a linqdatasour...
i have a split front-end and back-end access database. i am planning to move it into sql server. the front end will be c# linq to sql.
question:
is it going to be possible to have multiple users use this c# front end and for example be able to edit a table at the same time? you know that ms-access you can design a form with a table on i...
I had a rather large solution properly compiling until my power went out.
Now, I have a standard Linq to Sql DataContext class defined in one project, and it compiles properly, however another project that references that assembly refuses to compile Linq properly.
I'm getting compile errors like
'DataLayer.AdminDataContext': type use...
Hi,
I am trying to strongly type a query for 3 ef objects using linq to sql. There are one-to-many relationships with product and category. My classes contain navigation properties and look like this.
public partial class Product
{
public int ID {get;set;}
public string Name {get;set;}
public virtual ICollection<Group> NpGroup {get;se...
I have this requirement that i need to Update/Save all records from DatabaseA on ServerA when DatabaseB on ServerB Status is updated to FG-FRESH.
Example:
ServerB| DatabaseB
SerialNumber Status
0000001 Completed
0000002 FG-FRESH
0000003 FG-FRESH
ServerA | DatabaseA
SerialNumber Status
0000002 FG-FRESH
0000003 ...
I have a DBML on a single database in a named instance. The instance has a linked server to another MSSQL database in another server/instance. Both instances and databases have the same dbo-level user. Both databases are MSSQL 2008.
I have some C# code (Framework 3.5) that uses the DBML that accesses the tables and views and sprocs on D...
Hi,
I'm trying to convert the following SQL to LINQ. I've had success with 1 group by variable but couldn't get this to work. Any help would be appreciated.
select ContactID, EventID, Count=count(*)
from ScanLogs s, Exhibits e
where s.ExhibitID = e.ExhibitID
group by s.ContactID, e.EventID
The result looks something like this...
I created a stored procedure in SqlServer 2008 which returns XML using FOR XML but my intellisense of Data Context in Visual studio 2010 shows Void as return type.Should i change the return type manually? If so to what type?.
...
I want to convert Following sql server query with Linq-to-sql query . What I have to do. how it will be? I am using c#.
SELECT Table1.CRNo, Table2.StageId
FROM Table1 INNER JOIN Table2
ON Table1.CRNo = Table2.CRNo
WHERE (Table2.IsActive = 'true')
Table 1 and Table 2 are two tables. CRNo is identica...
I have a practise of setting UpdateCheck="Never" for most table properties in the DBML file. This is because I don't want the extra overhead from concurrency checking (see Turn Optimistic Concurrency Off Unless You Need It)
However, I have noticed a strange side effect of doing this. Can anyone explain this?
If I am updating a particul...
How do I convert this SQL query to LINQ-to-SQL?:
select
COUNT(ua.UserAlertID) as Alerts,
ph.LastName +' '+ ph.MiddleName as Name,
ph.Email,us.UserSystemID,
ur.UserStatus from PHUser ph
inner join UserSystem us on us.UserID=ph.UserID
inner join UserRole ur on ur.UserID=ph.UserID
inner join Role rr on rr.RoleID=ur.Role...
I am using Linq to Sql as my ORM and I have a list of Ids (up to a few thousand) passed into my retriever method, and with that list I want to grab all User records that correspond to those unique Ids. To clarify, imagine I have something like this:
List<IUser> GetUsersForListOfIds(List<int> ids)
{
using (var db = new UserDataCo...
Hi,
I wanted to use a method I created inside a query coz i need to implement a peculiar type of filter...
return manager.Clients.SelectAll().Where(cli => cli.Name.SatisfyFilter(filter.Name) && cli.LastName.SatisfyFilter(filter.LastName) && cli.MiddleName.SatisfyFilter(filter.MiddleName)).ToList();
But i get the:
"Method 'Boolean Sa...
Hello SO,
This is my first attempt at updating a database using LINQtoSQL. At least, it's my first if you don't count the tutorials I've followed. Unfortunately, The tutorials that I have found don't offer much more than updating a single table. I'm attempting to update a DB Model that's a bit more complex.
I have a Stream table:
[Tab...
I have a view that is a composition form several sources (for read only), so none of the keys are unique. Can I create a key to use in Linq-to-sql, or should I just create an composite column in my view that is a concatenation of all the keys.
...