I have a windows form, on which I display data from a local database.
I'd like to also connect to a remote database, and display some other data from there.. however, this remote database could be down, or slow.
I don't want the UI to freeze while I try to connect to this remote database.
So knowing nothing about threading or thread-...
I'm looking for a solution on how to configure Linq DataContext in Class Library Project in order to use Connection String in web.config of web application.
Your advice would be much appreciated.
...
With Linq To Sql - what is the best way to update the value of one table in a database when a value changes in a different table?
For example in TableA, there is a column called DateModified. TableA has an association to TableB. Now I want to set the value of the DateModified field to the current date every time the record changes in ta...
I validate data for a table made in the linq designer in the event OnValidate.
This event is fired when I insert records, but not is fired when I update records.
I have this code:
public bool Save(int id, string marca, string modelo, string año, string motor,
bool disponible, RuleList issues)
{
Usado u;
if (id == 0)
{
...
I want to remove an item from the result of a LINQ query before using it to databind. What is the proper way to do this?
The foreach in my illustration is the topic of my question. Illustration:
var obj =
(from a in dc.Activities
where a.Referrer != null
&& a.Referrer.Trim().Length > 12
&& a.Session.IP.NumProblems == 0...
I'm binding an ASP.NET control to the result of a LINQ query. I'd like to HtmlEncode one of the properties of the contained objects before binding to the control, but I want to do it without altering the data because I do a DataContext.SubmitChanges() later on. How can this be done?
Code that won't work:
var ds = (from s in dc.Search...
I have been trying out both Linq to Sql and EF in my ASP.NET MVC application. After switching to EF I realized my XML/JSON serialization output has extra cruft.
XML:
<Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<EntityKey>
<EntitySetName>Persons</EntitySetName>
<...
Hi folks,
I'm trying to do the following linq 2 sql extension method:
public static PagedList<T> ToPagedListOrNull<T>(this IQueryable<T> value,
int index,
int pageSize)
{
return value.Count() == 0
? null
: (value ...
I have a repository class that wraps my LINQ to SQL Data Context. The repository class is a business line class that contains all the data tier logic (and caching and such).
Here's my v1 of my repo interface.
public interface ILocationRepository
{
IList<Location> FindAll();
IList<Location> FindForState(State state);
IList<L...
I was expecting the following LINQ query to retrieve all contacts with the specified phone number but instead it returns all contacts that don't have a phone number at all.
var query = from contact in dc.Contacts
where contact.Phones.All(phone => phone.PhoneNumber == "5558675309")
select contact;
What am I doin...
I have a general question, and curiosity about LINQ and timeouts.
I have a live application running and I am receiving timeouts on the following code.
The following code, which is normal, and I don't see anything wrong:
private static tblUser GetUserLinq(string email, string password)
{
DataContext db = new DataCon...
OK here's my problem...
I have a LINQ partial class:
public partial class resp
{
public IEnumerable<RuleViolation> GetRuleViolations()
{
if (String.IsNullOrEmpty(respName))
yield return new RuleViolation("Responsibility name required", "respName");
yield break;
}
public bool IsValid
{
...
I'm looking for a way to handle a database-driven menu in ASP.NET MVC that doesn't violate the MVC principles. I want to replace the hard-coded, default, "Home, About" menu with something from my database. How would I wire this up? Would I just set up a ContentPlaceHolder in my Site.Master and have regenerated in my Views? That does...
I am building a new application based on MVC and considering LINQ-To-SQL/Entity Framework. I a have entity which has a numerical status Like (0 - Open, 1 - Active, 2 - Closed), Where should i Put the logic to show appropriate string (Enum??) in the view/controller or model which is generated automatically?
Should I move all such logic in...
In SQL Server you are able to have application role security, through which you are able to for example give specific permissions that originate from specific applications.
You can execute sp_SetAppRole() to set the application role but was wondering how this could be accomplished when using a LINQ2SQL datacontext with the least amount ...
I have to insert some data periodically in my SQL Server database. But the feeds where I read the data repeats some data that was inserted before. When I use Linq-to-SQL to insert into the DB either some data is duplicated, or a primary key violation exception is raised, depending on the primary key.
How to insert the data without dupli...
I'm using Linq2SQL and I'm pretty new to it.
I've got a User table and a UserData table, the idea being that properties for the User object can be added / removed by adding or removing rows in the UserData table. I did not come up with this particular design but I am more or less stuck with it (as long as I can come up with a solution)...
Hello. I am hoping you can help. I am developing a tiered website using Linq to Sql. I created a new class(or object) in DBML designer called memberState. This object is not an actual table in the database. I have this method in my middle layer:
public override IEnumerable(memberState) GetMembersByState(string @state)
{
using (Bulle...
The code, with two Linq-to-SQL queries, that I am trying to optimize is below:
var maxAInstant =
(
from a in db.As
select a.Instant
)
.Max();
var maxBInstant =
(
from b in db.Bs
select b.instant
)
...
I have a service level methods, which make few changes to database and I want them to use transaction control. Such methods can do following:
- LINQ SubmitChanges() functionality
- Calls to StoredProcedures
Component users can combine set of such elementary operations into something bigger.
I see that there is nice class TransactinSco...