context.Blogs.FromSql("SELECT * FROM dbo.Blogs").OrderBy(b => b.Name)
.
+ context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({0})", userSuppliedSearchTerm)
.
+ context.Blogs.FromSql("SELECT * FROM [dbo].[SearchBlogs]({@searchTerm})", new SqlParameter("@searchTerm", userSuppliedSearchTerm))
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ var connectionString = "connection string to database";
+
+ services
+ .AddEntityFrameworkSqlite()
+ .AddDbContext<MyContext>((serviceProvider, options) =>
+ options.UseSqlite(connectionString)
+ .UseInternalServiceProvider(serviceProvider));
+ }
+
+
+ optionsBuilder.ConfigureWarnings(warnings =>
+ warnings.Default(WarningBehavior.Ignore)
+ .Log(CoreEventId.IncludeIgnoredWarning, CoreEventId.ModelValidationWarning)
+ .Throw(RelationalEventId.QueryClientEvaluationWarning))
+
+
+ optionsBuilder.ConfigureWarnings(warnings =>
+ warnings.Default(WarningBehavior.Ignore)
+ .Log(CoreEventId.IncludeIgnoredWarning, CoreEventId.ModelValidationWarning)
+ .Throw(RelationalEventId.QueryClientEvaluationWarning))
+
+
+ var blogs = context.Blogs
+ .Where(b => EF.Property<DateTime>(b, "LastUpdated") > DateTime.Now.AddDays(-5))
+
+
+ context.Blogs.Include(blog => blog.Posts);
+
+
+ context.Blogs
+ .Include(blog => blog.Posts).ThenInclude(post => post.Tags);
+
+
+ context.Blogs
+ .Include(blog => blog.Posts).ThenInclude(post => post.Tags).ThenInclude(tag => tag.TagInfo)
+ .Include(blog => blog.Contributors);
+
+
+ context.Blogs.Include(blog => blog.Posts);
+
+
+ context.Blogs
+ .Include(blog => blog.Posts).ThenInclude(post => post.Tags);
+
+
+ context.Blogs
+ .Include(blog => blog.Posts).ThenInclude(post => post.Tags).ThenInclude(tag => tag.TagInfo)
+ .Include(blog => blog.Contributors);
+
+
+ context.Blogs.Include(blog => blog.Posts);
+
+
+ context.Blogs
+ .Include(blog => blog.Posts).ThenInclude(post => post.Tags);
+
+
+ context.Blogs
+ .Include(blog => blog.Posts).ThenInclude(post => post.Tags).ThenInclude(tag => tag.TagInfo)
+ .Include(blog => blog.Contributors);
+
+
+ context.Blogs.Include("Posts");
+
+
+ context.Blogs.Include("Posts.Tags");
+
+
+ context.Blogs
+ .Include("Posts.Tags.TagInfo')
+ .Include("Contributors");
+
+ public IServiceCollection ConfigureDesignTimeServices(IServiceCollection serviceCollection)
.
+
+
+ The name of the assembly that contains the design time services.
+
+
+ The NuGet package name that contains the design time services.
+
+ public IServiceCollection ConfigureDesignTimeServices(IServiceCollection serviceCollection)
.
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ var connectionString = "connection string to database";
+
+ services.AddDbContext<MyContext>(options => options.UseSqlServer(connectionString));
+ }
+
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ var connectionString = "connection string to database";
+
+ services.AddDbContext<MyContext>(options => options.UseSqlServer(connectionString));
+ }
+
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ var connectionString = "connection string to database";
+
+ services.AddDbContext<MyContext>(ServiceLifetime.Scoped);
+ }
+
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ var connectionString = "connection string to database";
+
+ services
+ .AddEntityFrameworkSqlServer()
+ .AddDbContext<MyContext>((serviceProvider, options) =>
+ options.UseSqlServer(connectionString)
+ .UseInternalServiceProvider(serviceProvider));
+ }
+
+ true
if the current object is equal to the other parameter; otherwise, false
.true
if the current object is equal to the other parameter; otherwise, false
.true
if the specified false
.true
if the specified false
.null
.
+ The second null
.
+ true
if the value of false
.null
.
+ The second null
.
+ true
if the value of false
.true
if false
.true
if false
.String.Empty
if the String.Empty
if the
+ [BaseTypeRequired(typeof(IComponent)] // Specify requirement
+ public class ComponentAttribute : Attribute
+ {}
+
+ [Component] // ComponentAttribute requires implementing IComponent interface
+ public class MyComponent : IComponent
+ {}
+
+ Function definition table syntax:
+ ("o", o);
+ }
+ ]]>
+ In some other cases, the input value is returned unmodified. This makes it easier to use the argument checks in calls to base class constructors
+ or property setters:
+
+
+ var query = from s in Students
+ join a in Addresses on s.AdressID equals a.ID into addresses
+ from a in addresses
+ select new { s, a };
+
+
+ var query = from s in Students
+ join a in Addresses on s.AdressID equals a.ID
+ select new { s, a };
+
+
+ var result = (from s in Students
+ select s).Aggregate(0, (totalAge, s) => totalAge + s.Age);
+
+
+ var result = (from s in Students
+ select s.Name).Aggregate((allNames, name) => allNames + " " + name);
+
+
+ var result = (from s in Students
+ select s).All();
+
+
+ var result = (from s in Students
+ select s).Any();
+
+
+ var query = (from s in Students
+ select s.ID).Average();
+
+
+ var query = (from s in Students
+ select s.ID).Cast<int>();
+
+
+ var query = (from s in Students
+ select s).Concat(students2);
+
+
+ var query = (from s in Students
+ select s).Contains (student);
+
+
+ var query = (from s in Students
+ select s).Count();
+
+
+ var query = (from s in Students
+ select s).DefaultIfEmpty ("student");
+
+
+ var query = (from s in Students
+ select s).Distinct();
+
+
+ var query = (from s in Students
+ select s).Except(students2);
+
+
+ var query = (from s in Students
+ select s).First();
+
+
+ var query = from s in Students
+ where s.First == "Hugo"
+ group s by s.Country;
+
+
+ var query = (from s in Students
+ select s).Intersect(students2);
+
+
+ var query = (from s in Students
+ select s).Last();
+
+
+ var query = (from s in Students
+ select s).LongCount();
+
+
+ var query = (from s in Students
+ select s.ID).Max();
+
+
+ var query = (from s in Students
+ select s.ID).Min();
+
+
+ var query = (from s in Students
+ select s.ID).OfType<int>();
+
+
+ var query = (from s in Students
+ select s).Reverse();
+
+
+ var query = (from s in Students
+ select s).Single();
+
+
+ var query = (from s in Students
+ select s).Skip (3);
+
+
+ var query = (from s in Students
+ select s.ID).Sum();
+
+
+ var query = (from s in Students
+ select s).Take(3);
+
+
+ var query = (from s in Students
+ select s).Union(students2);
+
+
+ var query = from s in Students
+ where s.First == "Hugo"
+ select s;
+
+
+ MainSource (...)
+ .Select (x => x)
+ .Distinct ()
+ .Select (x => x)
+
+
+ Naively, the last Select node would resolve (via Distinct and Select) to the
+ MainSource (MainSource (...).Select (x => x).Distinct ())
+ .Select (x => x)
+
+
+ Now, the last Select node resolves to the new
+ x.GroupBy (k => key, e => element, (k, g) => result)
+
+ is therefore equivalent to:
+
+ c.GroupBy (k => key, e => element).Select (grouping => resultSub)
+
+ where resultSub is the same as result with k and g substituted with grouping.Key and grouping, respectively.
+
+ from order in ...
+ select order.OrderItems.Count()
+
+ In this query, the
+ from c in Customers
+ from o in (from oi in OrderInfos where oi.Customer == c orderby oi.OrderDate select oi.Order)
+ orderby o.Product.Name
+ select new { c, o }
+
+ This will be transformed into:
+
+ from c in Customers
+ from oi in OrderInfos
+ where oi.Customer == c
+ orderby oi.OrderDate
+ orderby oi.Order.Product.Name
+ select new { c, oi.Order }
+
+ As another example, take the following query:
+
+ from c in (from o in Orders select o.Customer)
+ where c.Name.StartsWith ("Miller")
+ select c
+
+ (This query is never produced by the
+ from o in Orders
+ where o.Customer.Name.StartsWith ("Miller")
+ select o
+
+