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 IRepository<T> where T : BaseEntity | |
{ | |
IUnitOfWork UnitOfWork { get; } | |
IQueryable<T> All<T>() where T : BaseEntity; | |
T Find<T>(Expression<Func<T, bool>> predicate) where T : BaseEntity; | |
bool Contains<T>(Expression<Func<T, bool>> predicate) where T : BaseEntity; | |
} |
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
git rm -rf --cached . | |
git add . |
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
[Serializable] | |
public class Person | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public int Age { get; set; } | |
} | |
var serializer = new XmlSerializer(typeof(Person)); | |
string xml; |
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
@media print { | |
div.panel { | |
page-break-inside: avoid; | |
} | |
.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { | |
float: left; | |
} | |
.col-sm-12 { |
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
using System; | |
using System.IO; | |
class Program | |
{ | |
static void Main() | |
{ | |
// Read all bytes in from a file on the disk. | |
byte[] file = File.ReadAllBytes("C:\\ICON1.png"); |
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
List<Person>.Enumerator e = people.GetEnumerator(); | |
try | |
{ | |
Person v; | |
while (e.MoveNext()) | |
v = e.Current; | |
} | |
finally | |
{ | |
System.IDisposable d = e as System.IDisposable; |
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 AssertionConcern | |
{ | |
public static void AssertArgumentEquals(object object1, object object2, string message) | |
{ | |
if (!object1.Equals(object2)) | |
{ | |
throw new InvalidOperationException(message); | |
} | |
} |
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 DisposableResourceHolder : IDisposable { | |
private SafeHandle resource; // handle to a resource | |
public DisposableResourceHolder(){ | |
this.resource = ... // allocates the resource | |
} | |
public void Dispose(){ | |
Dispose(true); |
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 query = _context.TableOuter | |
.Join(_context.TableInner, | |
outer => outer.Id, | |
inner => inner.ForeignId, | |
(outer, inner) => new | |
{ | |
outer, | |
inner | |
}) | |
.Where(x => x.inner.Property == value).Select(x => x.inner).SingleOrDefault(); |
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
using (MyContext context = new MyContext()) | |
{ | |
// This will show the SQL in the Output -> Debug window. | |
context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); | |
// LINQ expressions below... | |
} |