S
S
Sergey Gorlanov2013-12-23 14:32:27
SQL
Sergey Gorlanov, 2013-12-23 14:32:27

Autogenerator c# classes for stored procedures?

Good afternoon.
I came across new projects in C# + MsSQL
There were only dlls, I used dotPeek to uncompile. I
found that a number of classes ending in Result are actively used to communicate with the database and get data from it, the classes themselves are apparently generated, and not written by hand. I came to this conclusion because there are a lot of them (for each stored procedure). Well, Google gave a lot of results on auto-generation of classes for stored ones. But I have not found such a generator. Here is an example result class for storage:

using System.Data.Linq.Mapping;

namespace DatabaseLib
{
  public class FindUsersResult
  {
    private long? _Id;
    private string _Login;

    [Column(DbType = "BigInt", Storage = "_Id")]
    public long? Id
    {
      get
      {
        return this._Id;
      }
      set
      {
        long? nullable1 = this._Id;
        long? nullable2 = value;
        if ((nullable1.GetValueOrDefault() != nullable2.GetValueOrDefault() ? 1 : (nullable1.HasValue != nullable2.HasValue ? 1 : 0)) == 0)
          return;
        this._Id = value;
      }
    }

    [Column(DbType = "NVarChar(255)", Storage = "_Login")]
    public string Login
    {
      get
      {
        return this._Login;
      }
      set
      {
        if (!(this._Login != value))
          return;
        this._Login = value;
      }
    }
  }
}

Surely in the original file there is a note of what was generated, but after decompilation - there are no comments.
Can you tell me what kind of generator? Or, which way can you go?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2013-12-23
@gorlanovS

Incredibly high probability that this is a standard DBML generator, it is built into the studio.
Try adding linq to sql classes to the project. And already add the dbo.FindUsersResult procedure to it. I think the generated *.cs-file will be very similar to yours.

A
Artem, 2013-12-23
@artemf

Right, it's most likely the built-in generator msdn.microsoft.com/en-us/library/bb126445.aspx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question