Who prefers ObjectSet or CreateQuery in EF 4?

I coded below. But I find another secand part method. which is more preferred than others. what is the difference? who has more performance than others?

public T Single(Func<T, bool> predicate)
{
    return _context.CreateQuery<T>("[" + typeof(T).Name + "]").Where(predicate).Single();
}

OTHER USE

public T Single(Func<T, bool> predicate)
{
    return _objectSet.Single<T>(predicate);
}

who prefers another?

+3
source share
2 answers

These are completely different things, with completely different goals.

ObjectSet<T>- This is a strongly typed property that allows you to run LINQ queries to the conceptual model. ( ctx.Apples.Where(x => x.Color == "Red")).

CreateQuery<T> - , SQL . EntitySQL. (SELECT * FROM dbo.Apples WHERE Color = "Red")

ObjectSet<T> , ObjectSet, . CreateQuery<T>, , , - EntitySQL, - , - . , ObjectSet<T>, CLR ( ..) SQL ( , PK ..).

@adrift, IObjectSet<T> , , , proxy/wrapper CreateQuery<T> .

Entity Framework 4.0 CreateQuery<T>. ObjectSet<T>, .

+5

IObjectSet, , IObjectSet<TEntity> . , . .

0

Source: https://habr.com/ru/post/1780235/


All Articles