using (NorthwindDataContext context =new NorthwindDataContext()) { context.Log = Console.Out; Customer customer = context.Customers.Single<Customer> (c => c.CustomerID.Equals("ALFKI")); }
또는 디비거에서 확인 해보기
출처 : http://www.u2u.info/Blogs/Kris/Lists/Posts/Post.aspx?ID=11
실제 디버그에서 출력되는 화면
System.Diagnostics.Debugger: 참조
MyDataContext db = new MyDataContext(); db.Log = new DebuggerWriter(); Here's the code: using System; using System.Diagnostics; using System.Globalization; using System.IO; using System.Text; namespace Vandermotten.Diagnostics { /// <summary> /// Implements a <see cref="TextWriter"/> for writing information to the debugger log. /// </summary> /// <seealso cref="Debugger.Log"/> public class DebuggerWriter : TextWriter { private bool isOpen; private static UnicodeEncoding encoding; private readonly int level; private readonly string category; /// <summary> /// Initializes a new instance of the <see cref="DebuggerWriter"/> class. /// </summary> public DebuggerWriter() : this(0, Debugger.DefaultCategory) { } /// <summary> /// Initializes a new instance of the <see cref="DebuggerWriter"/> class with the specified level and category. /// </summary> /// <param name="level">A description of the importance of the messages.</param> /// <param name="category">The category of the messages.</param> public DebuggerWriter(int level, string category) : this(level, category, CultureInfo.CurrentCulture) { } /// <summary> /// Initializes a new instance of the <see cref="DebuggerWriter"/> class with the specified level, category and format provider. /// </summary> /// <param name="level">A description of the importance of the messages.</param> /// <param name="category">The category of the messages.</param> /// <param name="formatProvider">An <see cref="IFormatProvider"/> object that controls formatting.</param> public DebuggerWriter(int level, string category, IFormatProvider formatProvider) : base(formatProvider) { this.level = level; this.category = category; this.isOpen = true; } protected override void Dispose(bool disposing) { isOpen = false; base.Dispose(disposing); } public override void Write(char value) { if (!isOpen) { throw new ObjectDisposedException(null); } Debugger.Log(level, category, value.ToString()); } public override void Write(string value) { if (!isOpen) { throw new ObjectDisposedException(null); } if (value != null) { Debugger.Log(level, category, value); } } public override void Write(char[] buffer, int index, int count) { if (!isOpen) { throw new ObjectDisposedException(null); } if (buffer == null || index < 0 || count < 0 || buffer.Length - index < count) { base.Write(buffer, index, count); // delegate throw exception to base class } Debugger.Log(level, category, new string(buffer, index, count)); } public override Encoding Encoding { get { if (encoding == null) { encoding = new UnicodeEncoding(false, false); } return encoding; } } public int Level { get { return level; } } public string Category { get { return category; } } } }
'LINQ & Entity' 카테고리의 다른 글
[Linq Null Value] 빈값 셀렉트 (2) | 2011.03.03 |
---|---|
DataSet 을 Linq로 쿼리하기 (0) | 2010.10.06 |
[URL]101 LINQ Samples (0) | 2010.04.26 |
[Attach 메소드]연결되지 않은 엔티티는 제거할 수 없습니다. (0) | 2010.04.09 |
dataContext 동시에 insert/ update /delete 진행하기 (0) | 2010.04.06 |
[UNION]두 시퀀스 연결(LINQ to SQL) (0) | 2010.02.25 |
Func(T, TResult) Delegate 사용해보기 (0) | 2010.02.24 |
scottgu 아저씨 LINQ 쿼리 모음정리 (0) | 2010.02.23 |
[LINQ TO SQL] DataContext에서 조인하기 (0) | 2010.02.23 |
Lambda Expression Example (0) | 2010.02.23 |