Mercurial > pub > bltoolkit
diff Source/Data/Linq/DataContextInfo.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Source/Data/Linq/DataContextInfo.cs Thu Mar 27 21:46:09 2014 +0400 @@ -0,0 +1,47 @@ +using System; + +namespace BLToolkit.Data.Linq +{ + using Data.Sql.SqlProvider; + using Mapping; + + public class DataContextInfo : IDataContextInfo + { + public DataContextInfo(IDataContext dataContext) + { + DataContext = dataContext; + DisposeContext = false; + } + + public DataContextInfo(IDataContext dataContext, bool disposeContext) + { + DataContext = dataContext; + DisposeContext = disposeContext; + } + + public IDataContext DataContext { get; private set; } + public bool DisposeContext { get; private set; } + public string ContextID { get { return DataContext.ContextID; } } + public MappingSchema MappingSchema { get { return DataContext.MappingSchema; } } + + public ISqlProvider CreateSqlProvider() + { + return DataContext.CreateSqlProvider(); + } + + public IDataContextInfo Clone(bool forNestedQuery) + { + return new DataContextInfo(DataContext.Clone(forNestedQuery)); + } + + public static IDataContextInfo Create(IDataContext dataContext) + { +#if SILVERLIGHT + if (dataContext == null) throw new ArgumentNullException("dataContext"); + return new DataContextInfo(dataContext); +#else + return dataContext == null ? (IDataContextInfo)new DefaultDataContextInfo() : new DataContextInfo(dataContext); +#endif + } + } +}