linq-to-sql

Extend linq-to-sql partial class to avoid writing a property?

I have a linq-to-sql class. I have a property "Password" for which I want to call the underlying ASP.NET Membership provider. Thus, I do not want this property written out directly but via my own code. I basically want to create a facade/proxy for this property such that I may use the underlying membership provider or a custom stored pro...

How do I get this sql to linq? Multiple groups

For a db person, LINQ can be frustrating. I need to convert the following SQL into Linq. SELECT COUNT(o.objectiveid), COUNT(distinct r.ReviewId), l.Abbreviation FROM Objective o JOIN Review r on r.ReviewId = o.ReviewId and r.ReviewPeriodId = 3 and r.IsDeleted = 0 JOIN Position p on p.PositionId = r.EmployeePositionId ...

LINQ Generic Query with inherited base class?

I am trying to write some generic LINQ queries for my entities, but am having issue doing the more complex things. Right now I am using an EntityDao class that has all my generics and each of my object class Daos (such as Accomplishments Dao) inherit it, am example: using LCFVB.ObjectsNS; using LCFVB.EntityNS; namespace Accomplishment...

Same Salt, Different Encrypted Password is not working? Using Linq to update password.

Hello, I am running into a wall regarding changing the password and was wondering if anyone had any ideas. Here are the database values prior to changing the password: Clear Text password = abc1980 Encrypted Password = Yn1N5l+4AUqkOM3WYO7ww/sCN+o= Salt = 82qVIhUIoblBRIRvFSZ1fw== After I change my password to abc1973, salt remains t...

2 listbox to exchange value with DBML

Hi, i'have two Listbox. the think is i do the transfert like : click on field in the left listbox, hit "move right" button and it wll display in the right list box.' The other think it's the first Listbox is bind on Dataset and the second on Entity (Linq-to sql). So when i click on the move next i do that : Dim newSite As New List(Of v...

LINQ to Entities pulling back entire table

In my application I'm pulling back a user's "feed". This contains all of that user's activities, events, friend requests from other users, etc. When I pull back the feed I'm calling various functions to filter the request along the way. var userFeed = GetFeed(db); // Query to pull back all data userFeed = FilterByUse...

Is there any class generator for bltoolkit?

Is there any class generator for bltoolkit? ...

Replacing NHibernate with LINQ to SQL or LINQ to EF

We have a great project that use NHibernate as ORM. We want to migrate to L2S or L2EF. Can we do everything that we do by NHibernate? Do you propose us that doing this work? What is the advantages and disadvantages of this work? Are these two ORMs have common capabilities? Note: Our project written in C#. ...

How to equal two strings case sensitively in Linq to SQL?

How to equal two strings case sensitively in Linq to SQL (in a where query)? Thanks. ...

Linq to SQL ordered child collection

Is there a way to define a default order column from a child collection? In my case, I have a Form entity that has a collection of FormItem entities called FormItems. FormItem has a property called DisplayOrder (int). I want to make sure that any Form entities I return from a method have that collection properly ordered. Is there a way t...

how to pass a parameter safely into linq to sql

If I want to get a user that has the email address of '[email protected]', how do I pass that as a parameter in linq? ie.: var a = from u in Users where u.Email = @email Select u; So this would be used in my method: public static GetuserByEmail(string email) Do I just pass in the variable or? ...

How do you bind SQL Data to a .NET DataGridView?

I am trying to bind a table in an SQL database to a DataGridView Control. I would like to make it so that when the user enters a new line of data in the DataGridView that a record is automatically added to the database. Here is my current attempt... BOMClassesDataContext DB = new BOMClassesDataContext(); Form_Load() { ...

Returning the PK during a linq to sql insert

I want to return the PK ID when I insert a new user via linq to sql. how can I do this? i.e. is there anything built in or do I have to do 2 queries? ...

Dynamic Linq help, different errors depending on object passed as parameter?

I have an entityDao that is inherbited by everyone of my objectDaos. I am using Dynamic Linq and trying to get some generic queries to work. I have the following code in my generic method in my EntityDao : public abstract class EntityDao<ImplementationType> where ImplementationType : Entity { public ImplementationType getOneByValu...

Updating an entity with linq to sql, do I need to call attach first?

My code looks like: Entity e = new Entity(); e.name = "..."; e.blah = 234; MyDb.UpdateEntity(e); public static void UpdateEntity(Entity e) { using(MyDatacontext dc = new MyDataContext()) { dc. ????????? } } So what do I do here to update the entity? note: i just called it entity here, its something else in...

Cannot add table to context - LINQ-To-SQL

Hey, I'd be happy to give you more info if you need, just ask for it. I have in my database a table of articles, a table of tags and a link table. The article table has values like Id, Subject etc etc, the tags only have Id and Tag. The link has TagId and ArticleId. The problem is that when I drag drop the link-table nothing happens! ...

Cannot attach an entity that already exists.

i am trying to update code via Linq, but getting this error Cannot attach an entity that already exists. C# code is here var con = (from c in cmsContentTable where c.ContentName == contentId select c).FirstOrDefault(); cmsContentTable.Attach(con); con.ContentData = "New Value"; cmsContentTable.Conte...

WCF "DataContext accessed after Dispose"

I have an application with numerous WCF services that make use of LINQ-To-SQL as the data access model. I am having lots of problems with the "DataContext accessed after Dispose" exception. I understand what this exception is and that it is occurring because I have not "initialised" the data that is trying to be accessed. I've read many ...

Problem with interface implementation in partial classes.

I have a question regarding a problem with L2S, Autogenerated DataContext and the use of Partial Classes. I have abstracted my datacontext and for every table I use, I'm implementing a class with an interface. In the code below you can see I have the Interface and two partial classes. The first class is just there to make sure the class ...

LinqToSql: How can I create a projection to adhere to DRY?

Just wondering if there is a way to take some of the repitition out of a LINQ to SQL projected type. Example: Table: Address Fields: AddressID, HouseNumber, Street, City, State, Zip, +20 more Class MyAddress: AddressID, HouseNumber, Street (Only 3 fields) LINQ: from a in db.Addresses select new MyAddress { AddressID = a.AddressI...