This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class LinqVisualizer | |
{ | |
public static void Dump<Tkey, Telement>(this IEnumerable<IGrouping<Tkey, Telement>> source) | |
{ | |
foreach (var item in source) | |
{ | |
Console.WriteLine("Root Level Key : {0}", item.Key); | |
foreach (var group in item) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var context = new ConferenceDb(); | |
var query = context.Set<Conference>().AsNoTracking(); | |
var predicate = ExpressionBuilder.MakePredicate<Conference>(new List<ExpressionModel>(new[] { | |
new ExpressionModel() { | |
Operator = ExpressionBuilder.ExpressionOperators.Equals, | |
PropertyName = "Slug", | |
Value = "Test" | |
}, | |
new ExpressionModel() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class QueryableExtension | |
{ | |
public static dynamic Build<Tobject>(this Tobject source, string propertyName) | |
{ | |
var propInfo = typeof(Tobject).GetProperty(propertyName); | |
var parameter = Expression.Parameter(typeof(Tobject), "x"); | |
var property = Expression.Property(parameter, propInfo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class QueryableExtension | |
{ | |
/// <summary> | |
/// <remarks> | |
/// Sampe Usage - | |
/// 1. queryableObject.GetSelectList(x => x.IdField, x => x.NameField); | |
/// 2. queryableObject.GetSelectList(x => x.IdField, x => x.NameField).WithDefaultItem("Select a project"); | |
/// </remarks> | |
/// </summary> | |
/// <typeparam name="T"></typeparam> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyDbContext db = new MyDbContext(); | |
List<SelectListItem> selectedItems = new List<SelectListItem>(); | |
if (type == null) return selectedItems; | |
if (type == typeof(TestDemo)) | |
selectedItems = db.TestDemo.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }).ToList(); | |
if (type == typeof(TestDemo1)) | |
selectedItems = db.TestDemo1.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }).ToList(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Expression<Func<T,T,T>> BuildIt<T>() | |
{ | |
var paramExprA = Expression.Parameter(typeof(T), "a"); | |
var paramExprB = Expression.Parameter(typeof(T), "b"); | |
var body = BinaryExpression.Add(paramExprA, paramExprB); | |
var lambda = Expression.Lambda<Func<T, T, T>>(body, paramExprA, paramExprB); | |
return lambda; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class QueryableExtension | |
{ | |
public static IEnumerable<SelectListItem> GetTable<T>(this IQueryable<T> source) | |
{ | |
KeyValuePair<PropertyInfo, PropertyInfo> sourceDestPropMap1 | |
= new KeyValuePair<PropertyInfo, PropertyInfo>( | |
// Text prop of selected item | |
typeof(SelectListItem).GetProperty("Text"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Runtime.InteropServices.ComTypes; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using EnvDTE80; | |
using EnvDTE90a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using System.Linq; | |
using System.Collections.Generic; | |
using EnvDTE; | |
namespace Common | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using System.Threading.Tasks; | |
using SampleService.Contracts; | |
using WcfDynamicProxy.Tests.Helper; | |
using NUnit.Framework; |