Skip to content

Instantly share code, notes, and snippets.

View rusith's full-sized avatar
🏠
Working from home

Shanaka Rusith rusith

🏠
Working from home
View GitHub Profile
...
var repo = unit.InvoicesViewRepository;
var filter = repo.Get();
if (!string.IsNullOrWhiteSpace(search))
{
filter.
Where.ShipTo.Contains(search).
Or.FactoryInvoiceNo.Contains(search)
.Or.No.Contains(search).Filter();
// List
unit.Procedures.SPC_GetOrders_List<OrderDetailModel>();
// Single
int deleted = unit.Procedures.SPC_DeleteOrder_Single<bool>(100);
// Void
unit.Procedures.SPC_DeleteOrder_Void(100);
// Executing a procedure
unit.Procedures.SPC_GetOrders<OrderDetailModel>_List(100);
var unit = Context.Unit()
var userRepository = unit.UserRepository; // getting the repository
var users = userRepository.Get().Where.GivenName.Contains("John").Filter().Query().ToList(); // Getting objects
if (users.Count < 1)
return null;
var user = users.First();
user.GivenName = "Doe"; // Updating the object .will update when committing changes
userRepository.Update(user);
var rusith = userRepository.Get().Where.GivenName.Contains("Rusith").Filter().Top(1).Query().FirstOrDefault(); // Getting an object
userRepository.Remove(rusith); // deleting an object
// An example using Ninject
using Example.DataAccess.Infrastructure;
using Example.DataAccess.Infrastructure.Interfaces;
using Ninject.Modules;
namespace Example.Business.Base.Concrete.Modules
{
internal class DataAccessModule : NinjectModule
{
public override void Load()
public sealed class OrderTypeEnum
{
private readonly int _value;
private OrderTypeEnum(int value)
{
_value = value;
}
public static implicit operator int(OrderTypeEnum @enum)
{
{
"table": "OrderType",
"valueColumn": "ID",
"nameColumn": "Name",
"type": "int"
}
@rusith
rusith / genie-configuration-example.json
Last active January 28, 2018 10:55
A simple configuration example for Genie https://rusith.github.io/Genie/
{
"connectionString": "...",
"projectPath": "...",
"baseNamespace": "...",
"ProjectFile": "...",
"enums": [
{
"table": "",
"valueColumn": "",
"nameColumn": "",
@rusith
rusith / Program.cs
Last active April 14, 2017 00:52 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);