Giter Site home page Giter Site logo

dynamicrm's Introduction

DynamicRM

DynamicRM is a lightwieght Dynamic Object Relational Mapper for .Net written in C#.

It uses non-traditional Entity objects that inherit from DynamicObject. This enables setting column values on Entity objects at will.

It's super easy to use. Just create a DynamicSqlConnection like this:

DynamicSqlConnection connection = new DynamicSqlConnection(new SqlConnection("<your connection string>"));

Query for a record:

dynamic entity = connection.QuerySingle("SELECT * FROM CUSTOMERS");

Query for multiple records:

IEnumerable<dynamic> entities = connection.Query("SELECT * FROM CUSTOMERS");

Insert a record into the database like this:

dynamic entity = new Entity("Customers");
entity.FirstName = "John";
connection.Insert(entity);

Update records in the database like this:

dynamic entity = connection.QuerySingle("SELECT * FROM CUSTOMERS");
entity.EntityTableName = "Customers";
entity.FirstName = "Doe";
connection.Update(entity);

Delete records in the database like this:

dynamic entity = connection.QuerySingle("SELECT * FROM CUSTOMERS");
entity.EntityTableName = "Customers";
connection.Delete(entity);

You are not required to Query for existing records to work with them, you can use disconnected Entity objects by setting their Primary Key:

dynamic entity = new Entity("Customers");
entity.Id = 10001;
entity.FirstName = "Doe";
connection.Update(entity);

DynamicSqlConnection also provides the basic Command methods that SqlConnection does, like ExecuteNonQuery/ExecuteReader/ExecuteScalar.

NOTE: There is a downside, in that intellisense will not work with the DynamicRM Entity objects. This is a trade off for speed of development.

Alternatively, you can subclass Entity and define your properties to get intellisense:

public class Customer : Entity
{
	public Customer() : base("Customers")
	{
	}

	public string FirstName
	{
		get
		{
			TryGetProperty(nameof(FirstName), out object result);
			return result as string;
		}
		set
		{
			SetProperty(nameof(FirstName), value);
		}
	}
}

You can then use the Generic Query methods as well:

Customer entity = context.QuerySingle<Customer>("SELECT * FROM CUSTOMERS");
entity.FirstName = "Doe";
context.Update(entity);

dynamicrm's People

Contributors

nazgul07 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.