This file contains hidden or 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 collection = new MongoCollection(tranny.TypeName, DB, DB.CurrentConnection); | |
var result = collection.Find(fly, tranny.Take, tranny.Skip); | |
// So that | |
IEnumberable<T> list = (IEnumerable<T>)result; | |
// Where T is the type is in the list |
This file contains hidden or 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
//Take this | |
public ActionResult Logins() | |
{ | |
var mapped = _repository | |
.Query(new GetLoginHistoryAndUser()) | |
.AutoMap<LoginHistory, LoginHistoryDisplay>() | |
.ToList(); | |
return View(new LoginHistoryViewModel { LoginHistory = mapped }); |
This file contains hidden or 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
//Mappings | |
CreateMap<DateTime, FormattedDateTime>().ConvertUsing<FormattedDateConverter>(); | |
CreateMap<string, bool>().ConvertUsing(x => x == "Y" || x.ToLowerInvariant() == "on" || x == "1"); | |
//Dictionary | |
var dict = new Dictionary<string,object>() { { "id", 2 },{ "date", DateTime.Now }, { "istrue", "Y" } }; | |
//Class |
This file contains hidden or 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 class AutoMapperProfile : Profile | |
{ | |
protected override void Configure() | |
{ | |
CreateMap<DateTime, FormattedDateTime>().ConvertUsing<FormattedDateConverter>(); | |
CreateMap<string, bool>().ConvertUsing(x => x == "Y" || x.ToLowerInvariant() == "on" || x == "1"); | |
DictionaryToClassConverter.ConvertFromDictionary(this, GetType().Assembly, x => x.ToLowerInvariant()); | |
} |
This file contains hidden or 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 class RepositoryConvention : IRegistrationConvention | |
{ | |
public void Process(Type type, StructureMap.Configuration.DSL.Registry registry) | |
{ | |
if (type.IsClass && type.GetInterfaces().Where(x => x == typeof(IRepository)).Any()) | |
{ | |
if (type.Name.Contains(GlobalSettings.DbType)) | |
{ | |
Type specificInterface = type.GetInterfaces().Where(x => x != typeof(IRepository)).First(); | |
registry.For(specificInterface).Use(type); |
This file contains hidden or 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 interface IQueryInvoker | |
{ | |
TViewModel Invoke<TViewModel>() where TViewModel : new(); | |
} | |
public class QueryInvoker : IQueryInvoker | |
{ | |
private readonly IObjectResolver _objectResolver; | |
public QueryInvoker(IObjectResolver objectResolver) |
This file contains hidden or 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 sql = "!" + application.Server.HtmlEncode(item.Sql).Replace("] ", "] ") + "!"; //Glimpse Sanitizer workaround |
This file contains hidden or 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 class Security | |
{ | |
public int SecurityId { get; set; } | |
public string Name { get; set; } | |
} | |
public class User | |
{ | |
public int UserId { get; set; } | |
public string FirstName { get; set; } |
This file contains hidden or 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
//This is how I use PetaPoco with structure map but I'm also using the IDatabase interface from my branch at http://github.com/schotime/petapoco | |
public class PetaPocoRegistry : Registry | |
{ | |
public PetaPocoRegistry() | |
{ | |
Scan(x => | |
{ | |
x.TheCallingAssembly(); | |
x.WithDefaultConventions(); |
This file contains hidden or 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
_databaseQuery.Execute("insert into temp1 (t) values (@0)" | |
, new SqlParameter() { SqlDbType = SqlDbType.VarBinary, Value = new byte[] {12, 1, 34, 234}}); |
OlderNewer