开发者

Linq2SQL, EDMX, interfaces (Preparing for a TDD enabled project!)

开发者 https://www.devze.com 2023-04-06 11:38 出处:网络
Is there an easy way to create a Linq to SQL class for my \"DomainModel\" off an EDMX (Entity Framework)?

Is there an easy way to create a Linq to SQL class for my "DomainModel" off an EDMX (Entity Framework)?

I assume this IS what I want to do...

At the moment I am guessing that if I have my myModel.edmx which is generated from SQL DB which contains an entity/table Levels and I want to create an interface for it.

Currently I have a "levels.cs" inside an "Entities" folder inside the DomainModel project. This should link to the Entity Framework and looks like this:

`

using System;
using System.Collections.Generic;
using DomainModel.Entities;
using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace DomainModel.Entities
{
    [Table(Name="Levels")]
    public class level
    {
        [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
        public System.Guid Id { get; internal set; }
        [Column] string UserId { get; set; }
        [Column]public int ScenId { get; set; }
        ...other fields...
    }

}

` Is it looking correct so far? Is there an easier way to auto generate these files? I take it the next step is to create an interface? The end goal is to develop this project using a test driven dev approach. The test part is fine, I've just ne开发者_JS百科ver had to develop in this fashion before


You should have a look at T4 to generate files.

When you use Entity Framework you talk about Linq to Entities and not about linq to SQL

0

精彩评论

暂无评论...
验证码 换一张
取 消