Linq to sql question - posted here because I can't find a specificlinq group...

F

Fritjolf

Hi.

I have some simple tables.
- ER_Person table (Person_Id, LogonId, FirstName, LastName, EMail)
- ER_Section table (Section_Id, SectionCode, SectionName)
- ER_PersonSection table (Person_Id, Section_Id)- this table takes
care of a many-to-many relationship between person and section. A
person can be connected to several sections and this table makes that
possible.

I'm using vs2008 and the objectdesigner.

In my application (Winforms) I retrieve a person:
var person = ProjectGlobal.rd.ER_Persons.Single(c => c.LogonId ==
ALogonId.ToUpper());
This is retrieved by the user entering a logonid in a textfield and
press fetch. The logonId is unique, enforced by business logic.

The person is fetched and I can change values and see that the
datacontext has pending updates, which it stores when I call the
datacontext.SubmitChanges();

This is a good, but then it comes to displaying the sections this
person is "attached to".
The person data is presented in textfields and is databound via a
BindingSource.

The sections for this person I would like to present in a grid.
var sections = from s in ProjectGlobal.rd.ER_Person_Sections
where s.ER_Person.LogonId ==
tefLogonId.Text.ToUpper() && s.ER_Person.Person_Id == s.Person_Id
select new { s.ER_Section.Section_Code,
s.ER_Section.SectionName };

Then I databind this result to the gridview.

the problem is that this probably isn't "best practices" and the other
problem is that I can't change or add new values....

Does anyone have any help regarding this master-detail problem... ?
and PLEASE don't just point me in the direction of a master grid
updating details in another grid...

Regards,
Fritjolf
 
M

Mr. Arnold

Fritjolf wrote:

I am more familiar Web Controls rather than Windows form controls in
this area, but what I think you need to use is LinqDataSource, which
will allow you do to the insert, update and delete from the control
bound to the Linq-2-SQL data source.


The link has examples on how to use the LinqDataSource from a Windows
form application.

http://msdn.microsoft.com/en-us/library/bb397964.aspx

This link shows and example, in asp.net, of what you can do if you can
use the LinqDataSource.

<http://www.beansoftware.com/ASP.NET-Tutorials/LINQDataSource-Control.aspx>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top