LINQ with Interface, changing Database Model Layer? ( ASP.NET MVC thoughts )

Last post 11-29-2008 11:20 AM by FilipEkberg. 2 replies.

Sort Posts:

  • LINQ with Interface, changing Database Model Layer? ( ASP.NET MVC thoughts )

    11-27-2008, 5:14 AM
    • Member
      1 point Member
    • FilipEkberg
    • Member since 11-27-2008, 5:10 AM
    • Sweden, Ronneby
    • Posts 2

    So i was thinking about using Interfaces to create a somewhat better API / Design.

    I want to have some control over my data when using LINQ to SQL and mapping my own classes seems unessesary and just out of order.

    What i was thinking was that i'll modify the .dbml which has the logic for my database. Why? Well i was thinking, since im using the asp.net mvc for my new web app.
    Having a controller taking a IEditable interface i can modify my underlying datalayer to only edit the specific properties.

    The real question is, how bad is it, design-wise, changing the .dbml.designer.cs by hand? Implementing new interfaces to the partial class definitons? Suggestions on a better way?

    Regards,
    Filip Ekberg

    Filed under: , , ,
  • Re: LINQ with Interface, changing Database Model Layer? ( ASP.NET MVC thoughts )

    11-27-2008, 6:55 AM
    Answer
    • Contributor
      6,377 point Contributor
    • Augi
    • Member since 10-18-2008, 5:46 AM
    • Czech Republic
    • Posts 1,102

    I think that editing any file ending with "designer.cs" is bad Wink Classes generated by LINQ To SQL are very well prepared for extension using partial classes and partial methods. It is not sufficient for your purposes? If you want to not have classes against DB tables in 1:1 ratio then you can use Entity Framework where you can specify mapping between DB tables and classes (and extend generated classes using partial classes and methods too).

    Don't forget to click "Mark as Answer" on the post that helped you.
  • Re: LINQ with Interface, changing Database Model Layer? ( ASP.NET MVC thoughts )

    11-29-2008, 11:20 AM
    • Member
      1 point Member
    • FilipEkberg
    • Member since 11-27-2008, 5:10 AM
    • Sweden, Ronneby
    • Posts 2
    Thank you for the answer. Using the partial classes and methods might be an interesting approach. I just want to try the "Simplify everything into an interface"-way and so far it seems to be working out just fine. I don't like the "specify my own mapping"-part, cause that just gives me extra work which i shouldnt need when using LINQ :) LINQ and Partial Classes should be more than enough! // Filip
Page 1 of 1 (3 items)