Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Time only portion of the date to use in LINQ query
Message
De
13/08/2015 12:23:07
 
 
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01622912
Message ID:
01623316
Vues:
97
>>>>>>AFAIK, if the query is executed against an instance of System.Data.Linq.DataContext linq will use Linq to Sql ; if against System.Data.Objects.ObjectContext then it will use Linq to Entities....
>>>>>
>>>>>In our case it's an interface based on another interface class which is defined as
>>>>>
>>>>>
>>>>> public interface IContext : IDisposable
>>>>>    {
>>>>>        IDbSet<T> Set<T>() where T : class;
>>>>>        int SaveChanges();
>>>>>        void SetModified(object entity);
>>>>>        void SetAdd(object entity);
>>>>>        void SetDeleted(object entity);
>>>>>        void ExecuteSqlCommand(string sql);
>>>>>        EntityState GetEntityState(object entity);
>>>>>        bool IsLoaded(object entity, string navigationPropertyName);
>>>>>        void Load(object entity, string navigationPropertyName);
>>>>>        DbPropertyValues GetOriginalValues(object entity);
>>>>>        DbPropertyValues GetCurrentValues(object entity);
>>>>>        void EnsurePaddedPrimaryKey<T>(T entity) where T : class;
>>>>>        ObjectContext CoreContext { get; }
>>>>>    }
>>>>>
>>>>>And the code in the method is
>>>>>
>>>>>
>>>>> var query = this._siriusContext.Max4Sale.Where(m4s => m4s.Type == max4sale.Type);
>>>>>
>>>>>_siriusContext is an instance of this
>>>>>
>>>>>
>>>>> public interface ISiriusSqlContext : IContext
>>>>>    {
>>>>>        IDbSet<AccActv> AccActv { get; set; } // acc_actv
>>>>>        IDbSet<Access> Access { get; set; } // access
>>>>>       etc. for all other tables/views
>>>>>  }
>>>>>
>>>>
>>>>So what is the Type on _siriusContext ?
>>>
>>>
>>>namespace SysManager.Repository
>>>{
>>>    public abstract class RepositoryBaseWithList<T, TList> : IRepositoryWithList<T, TList> 
>>>    where T : class where TList: class
>>>    {
>>>        protected readonly ISiriusSqlContext _siriusContext;
>>>
>>>        protected readonly IDbSet<T> _dbSet;
>>>        protected readonly IDbSet<TList> _dbSetList;
>>>        private readonly IExceptionParser _exceptionParser;
>>>etc.
>>
>>That tells me the Interface not the Type
>
>I am not sure what else can I provide. The particular class where I am using it is
>
>
> public class Max4SaleRepository : RepositoryBaseWithList<Max4Sale, Max4SaleList>, IMax4SaleRepository
>    {
>        public Max4SaleRepository(ISiriusSqlContext context)
>            : base(context)
>        {
>        }
Put a breakpoint at a point where you're executing a query against _siriusContext and look at the Type
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform